foreach my $line () { # etc } my @lines = sort ; print ; #### open(FILE, "< $file") or die "Cannot read $file: $!"; #### open(FILE, "cat $file |") or die "Cannot read $file: $!";