# prompt the user for the name of a source file, and # read all the lines from that file. # Then print out the lines in reverse order. print "What is the name of the source file? "; my $file = <>; chomp $file; open FILE, "< $file" or die "error reading $file - $!"; while ( <FILE> ) { push @lines, $_; } close FILE; foreach ( reverse @lines ) { print; }
In reply to File I/O #1
by vroom
in thread File Input and Output Exercises
by vroom
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |