Passing Filehandles by Reference : file handle « File « Perl
- Perl
- File
- file handle
Passing Filehandles by Reference
#!/bin/perl
open(READMEFILE, "f1") || die;
&readit(*READMEFILE); # Passing a filehandle to a subroutine
sub readit{
local(*myfile)=@_; # myfile is an alias for READMEFILE
while(<myfile>){
print;
}
}
Related examples in the same category