Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
Keep It Simple, Stupid
 
PerlMonks  

Re: $#array issue

by QM (Vicar)
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"; }

-QM
--
Quantum Mechanics: The dreams stuff is made of


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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (13)
As of 2014-04-16 15:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (432 votes), past polls