Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://992923]
help
Chatterbox?
stevieb is writing a little CUFP on how to control analog pins on an arduino from a Linux machine via I2C in light of Perl, JavaScript and Strandbeests. It also is a good real-world use-case to test my I2C dist.
[stevieb]: I just don't feel like going hardcore on anything today, so I thought I'd *use* my software instead of just write it

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2017-07-21 23:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (336 votes). Check out past polls.