Feed on
Posts
Comments

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 $!;
read_and_print(*F);
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

    c0b66bc93f4b…

    c0b66bc93f4b65b2adb1…

Did I get this wrong? Let me know!

Trackback URI | Comments RSS

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