programming-examples/perl/SystemFunction/Read from a file.pl
2019-11-15 12:59:38 +01:00

16 lines
364 B
Perl

#!/usr/local/bin/perl -w
use Getopt::Long;
my $ret = GetOptions ("f|filename:s");
my $filename = $opt_f || die "Usage: $0 -f filename\n";
# Open the file.
open (INPUT, "$filename") || die "Could not open file $filename : $!\n";
while (<INPUT>)
{
chop;
print "Line $. = <$_>\n";
}
close (INPUT);