in reply to Accessing 2 multidimensional arrays simultaneously
use strict; use warnings; my @arr1 = ( ['a','b','c'], ['d','e','f'], ['g','h','i'] ); my @arr2 = ( ['j','k','l'], ['m','n','o','p'], ['q','r'] ); #1 iterate using map and join print map {(join ',',@{$arr1[$_]},@{$arr2[$_]})."\n"} 0..$#arr1; #2 itarting modifying list separator { # scope to limit the effect of next statement local $"=','; # $LIST_SEPARATOR print map {"@{$arr1[$_]},@{$arr2[$_]}\n"} 0..$#arr1; } #3 or consuming arrays while (my $one = shift @arr1 and my $two = shift @arr2){ print +(join ',',@{$one},@{$two})."\n" }
L*
|
|---|