Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

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,
ihb


Comment on Re: Re: Non-destructive array processing
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2014-08-22 21:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (167 votes), past polls