Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: $#array issue

by QM (Parson)
on Jun 15, 2009 at 18:44 UTC ( #771753=note: print w/ replies, xml ) Need Help??

in reply to $#array issue

Lot's of good answers. Maybe this is short and sweet?

@array = (1..9); while (@array){ print +(pop @array), "\n"; }

If you really need that element for something along with the print, you can do this:

@array = (1..9); while (@array){ my $last = pop @array; do_something($last); print "$last\n"; }

Quantum Mechanics: The dreams stuff is made of

Comment on Re: $#array issue
Select or Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (10)
As of 2015-12-01 09:39 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (798 votes), past polls