Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
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 chilling in the Monastery: (16)
As of 2014-12-18 17:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (58 votes), past polls