# example 2 open(OUT,">revline.txt"); # opens revline.txt for writing while($l = ) # reads one line at a time from { $s = ""; # assigns the empth string to $s foreach $i (reverse(split(/\s+/, $l))) # creates an array $i and places { # the words from $l in reversed order into $i $s = "$s$i "; # makes $s a string of elements of $i } chop($s); # chops off one word at a time from # the front of string print OUT "$s\n"; # writes that word to filehandler } close OUT # closes the filehandle