in reply to Re^3: parallel procesing (List::Pairwise)
in thread parallel procesing

Assuming the same number of elements in each array you could:

push @$zip, map {shift @$_} ($array1, $array2) while @$array1;

If you instead wanted an array of paired rather than zipped elements you could:

push @$array, [map {shift @$_} ($array1, $array2)] while @$array1;

Note however that both of these destroy the original arrays.


Perl is environmentally friendly - it saves trees

Replies are listed 'Best First'.
Re^5: parallel procesing (List::Pairwise)
by ikegami (Patriarch) on Apr 07, 2008 at 03:13 UTC

    Non-destructive:

    my @array = map { [ $array1->[$_], $array2->[$_] ] } 0..$#$array1;

    or

    my @array; push @array, [ $array1->[$_], $array2->[$_] ] for 0..$#$array1;