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

Non-destructive array processing

by Juerd (Abbot)
on Jan 20, 2003 at 21:40 UTC ( #228501=perlmeditation: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my @array = 1..10;
    my $r = sub { \@_ }->(@array);
    ...
        print "Chunk: @chunk\n";
    }
    print "Original array is still intact! (@array)\n";
    
  2. or download this
    my @array = 1..10;
    for (my $i = 0; $i <= $#array; $i += 2) {
        my @chunk = @array[$i, $i + 1];
        print "Chunk: @chunk\n";
    }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://228501]
Approved by gmax
Front-paged by jarich
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (18)
As of 2015-07-30 14:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (271 votes), past polls