http://www.perlmonks.org?node_id=589200


in reply to For Loops and Reversing output

Something like this maybe?

use strict; use warnings; my $input = 'somelist'; # Original Line my @unsorted = qw(big small knobly broken round green); my @sorted = sort @unsorted; my @rocks; for (@sorted) { unshift @rocks, $_; print "$_\n" } print "\n"; print "The names, backwards, are:\n\t", join "\n\t", @rocks;

Prints:

big broken green knobly round small The names, backwards, are: small round knobly green broken big

DWIM is Perl's answer to Gödel