Or in case if arrays with $i and $j values are predefined, I would write it like that:
my @i=(1,2);
my @j=(3,4);
my @a = map {[$i[$_],$j[$_]]} 0..$#i;
foreach my $ij (@a){
my ($i, $j) = @{$ij};
say $i;
say $j;
}
OR if it's necessary to emulate TCL behaviour for different lengths of arrays with $i and $j values, I would write it like that:
my @i=(1,2);
my @j=(3,4,5);
my @len = sort(scalar(@i),scalar(@j));
my @a = map {[$i[$_],$j[$_]]} 0..$len[-1];
foreach my $ij (@a){
my ($i, $j) = @{$ij};
print $i."\n";
print $j."\n";
}
|