programming-examples/perl/File/Passing file handles to functions.pl

18 lines
315 B
Perl
Raw Normal View History

2019-11-15 12:59:38 +01:00
#!/usr/bin/perl
use warnings;
use strict;
my $file = "yourFile.txt";
open( FILE, $file ) or die( "Error opening $file: $!" );
my $filehandle = *FILE;
readhandle( $filehandle );
close( FILE ) or die( "Error closing $file: $!" );
sub readhandle
{
my $fh = shift();
print while ( <$fh> );
}