Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: For Loops and Reversing output

by Limbic~Region (Chancellor)
on Dec 12, 2006 at 00:36 UTC ( #589199=note: print w/ replies, xml ) Need Help??


in reply to For Loops and Reversing output

brusimm,
So you want to reverse without using reverse:

my $idx = $#array; while ($idx--) { print "$array[$idx]\n"; }
Oh, you really want to go forwards but have the output appear backwards?
my $output = ''; for my $elem (@array) { $output = "$elem\n" . $output; } $output .= "\n"; print $output;

Cheers - L~R


Comment on Re: For Loops and Reversing output
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://589199]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (17)
As of 2014-12-18 14:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (55 votes), past polls