Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Processing pairs of values from even-sized array

by johngg (Canon)
on Jun 03, 2011 at 12:30 UTC ( [id://907963]=note: print w/replies, xml ) Need Help??


in reply to Processing pairs of values from even-sized array

How about using splice?

knoppix@Microknoppix:~$ perl -E ' > @arr = ( 1 .. 6 ); > while ( @arr ) > { > ( $x, $y ) = splice @arr, 0, 2; > say qq{$x - $y}; > }' 1 - 2 3 - 4 5 - 6 knoppix@Microknoppix:~$

I hope this is helpful.

Cheers,

JohnGG

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2024-04-24 20:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found