Feed on

passing a filehandle to a subrouting in perl is slightly tricky; you’ll need to use  an asterisk.  for instance:

open (F, “/tmp/sesame”) || die $!;
sub read_and_print {
local (*G) = @_;  # Filehandle G is the same as filehandle F
while () { print; }

Bookmark and Share

if that was helpful ...

check out the other tips and tricks i've compiled on these pages. you might learn something else interesting!

One Response to “pass a filehandle to a perl subroutine”

  1. on 09 May 2008 at 7:57 am c0b66bc93f4b



Did I get this wrong? Let me know!

Trackback URI | Comments RSS

More blogs about http://desk.stinkpot.org:8080/tricks.