Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: For Loops and Reversing output

by GrandFather (Sage)
on Dec 12, 2006 at 00:40 UTC ( #589200=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://589200]
help
Chatterbox?
jedikaiti's brain hurts

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2017-09-22 22:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (269 votes). Check out past polls.

    Notices?