Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re^4: array pop

by GrandFather (Sage)
on Sep 11, 2012 at 05:24 UTC ( #992923=note: print w/replies, xml ) Need Help??

in reply to Re^3: array pop
in thread array pop

or more clearly, concisely and efficiently:

#! perl use strict; use warnings; my @array = ('a' .. 'e'); print 'Original @array contents: ', join(', ', @array), "\n"; my @popped = splice @array, 0, 3; print '@array now contains: ', join(', ', @array), "\n"; print 'The deleted elements: ', join(', ', @popped), "\n";

splice is your friend.

True laziness is hard work

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://992923]
[Corion]: I hope you're well too!
[thezip]: Where did you go? We've already set a record for all-time February rainfall here.
[Corion]: thezip: The Canary Islands - they have a constant climate
[Corion]: Maybe a bit too many old people, but for some do-nothing vacation for R&R exactly the right thing ;)=
[thezip]: That's awesome. I bet you feel totally rejuvenated and ready for the next thing.

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2017-02-23 17:03 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (349 votes). Check out past polls.