in reply to interleave two arrays

#the following gives: a 1 b 2 c 3 @arr1 = qw(a b c); @arr2 = qw(1 2 3); while (@arr1) {push @arr3, shift @arr1,shift @arr2} print "@arr3"; #BUT why does the following give an infinite loop? @arr1 = qw(a b c); @arr2 = qw(1 2 3); while ($push @arr3, shift @arr1,shift @arr2){}

Replies are listed 'Best First'.
Re^2: interleave two arrays
by choroba (Cardinal) on Feb 02, 2014 at 23:11 UTC
    See the documentation of push:
    Returns the number of elements in the array following the completed "push"

    Also, remove the dollar sign before "push".

    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
      thanks. how do i edit an item i've already posted?