Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: Re: Non-destructive array processing

by ihb (Deacon)
on Jan 22, 2003 at 19:01 UTC ( #229106=note: print w/replies, xml ) Need Help??

in reply to Re: Non-destructive array processing
in thread Non-destructive array processing

No, but you can use my:
my @array = 1..10; { my @array = @array; while (my @chunk = splice @array, 0, 2) { print "Chunk: @chunk\n"; } } print "Original array is still intact! (@array)\n";
Note though that modifications of an @array element (i.e. via $array[$n]) will disappear when the scope is left. This is simply because the inner @array simply is another variable with the values copied. The idea of Juerd's routine was that the elements would be aliased but the array different.

Hope I've helped,

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2016-10-22 00:08 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (291 votes). Check out past polls.