# File: fileReadWrite.pl # Title: Read a text file and print it line by line # Author: Mihaela Malita # Here is the file mary.txt: # Mary had a little lamb, # It's fleece was white as snow. # And everywhere that Mary went.. # Name of file? mary.txt # Mary had a little lamb, ... use strict; # all variables have to be declared with my use warnings; # gives warnings (same as >perl -w file3.pl ) my $filename; my $line; print "Name of the file (mary.txt)? "; $filename = ; chop($filename); #read from keyboard unless (open(IN,"$filename")) { #check if the file exists print "No file with such a name!"; exit; } while ($line = ) { #reads line by line the text file until End Of File (EOF) print "$line"; } close IN; exit;