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";
    }