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

i have a problem with zip subroutine. I've installed mentioned modules but the zip subroutine could not be executed because it isn't there. you said "I combine (my own) zip " where is the publicly available zip situated ???
  • Comment on Re^3: parallel procesing (List::Pairwise)

Replies are listed 'Best First'.
Re^4: parallel procesing (List::Pairwise)
by GrandFather (Saint) on Apr 06, 2008 at 21:01 UTC

    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

      Non-destructive:

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

      or

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