programming-examples/perl/File/Passing Filehandles by Reference.pl

11 lines
241 B
Perl
Raw Normal View History

2019-11-15 12:59:38 +01:00
#!/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;
}
}