Passing file name to functions : file handle « File « Perl
- Perl
- File
- file handle
Passing file name to functions
#!/usr/bin/perl
use warnings;
use strict;
my $file = "yourFile.txt";
print( "\n\nAnd finally...\n" );
readfile( $file );
sub readfile
{
my $file = shift();
local *FILE;
open( FILE, $file ) or die( "Error opening $file: $!" );
print while ( <FILE> );
}
Related examples in the same category