in reply to Foreach in mulitple arrays

yes, you're only missing commas:

@array1 = qw( a b ); @array2 = qw( c d ); @array3 = qw( e f ); foreach (@array1, @array2, @array3) { print; } # output # ------ # abcdef

If you wanted to go through them in parallel:

@array1 = qw( a b ); @array2 = qw( c d ); @array3 = qw( e f ); # Assumes all array are the same length. foreach (0..$#array1) { print($array1[$_], $array2[$_], $array3[$_], "\n"); } # output # ------ # ace # bdf

Replies are listed 'Best First'.
Re^2: Foreach in mulitple arrays
by magnus (Pilgrim) on Jun 13, 2005 at 15:37 UTC
    Thank you both. It worked fine.