Additions: Reading a whole file in at once Here's a program that reads a file and prints it in sorted order
open(MYINPUTFILE, "<filename.out"); # open for input
my(@lines) = <MYINPUTFILE>; # read file into list
@lines = sort(@lines); # sort the list
foreach $line (@lines) # loop thru list
print "$line"; # print in sort order
close(MYINPUTFILE); Reading a file line by line
# Good practice to store $_ value because
# subsequent operations may change it.
my($line) = $_;
# Good practice to always strip the trailing
# newline from the line.
# Convert the line to upper case.
$line =~ tr/[a-z]/[A-Z]/;
# Print the line to the screen and add a newline