Mega Code Archive

 
Categories / Perl / File
 

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> ); }