in reply to passing file handle to functions
Example from the perlfunc docs
# process argument list of files along with any includes foreach $file (@ARGV) { process($file, 'fh00'); } sub process { my($filename, $input) = @_; $input++; # this is a string increment unless (open($input, $filename)) { print STDERR "Can't open $filename: $!\n"; return; } local $_; while (<$input>) { # note use of indirection if (/^#include "(.*)"/) { process($1, $input); next; } #... # whatever } } See perliol for detailed info on PerlIO.
Hope it help
UnderMine
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: passing file handle to functions
by davorg (Chancellor) on May 18, 2006 at 07:54 UTC | |
by UnderMine (Friar) on May 18, 2006 at 11:32 UTC | |
by japhy (Canon) on May 18, 2006 at 11:38 UTC |