in reply to Efficient way to print 2 columns from 2 Array of Arrays next to each other
You are opening the TEMP filehandle for writing n times, with n being the number of elements of one of your arrays. And you're writing all your data n times, each time clobbering what you've written in the previous iteration.
From your description of the problem, you don't need nested loops, you only need one loop, because the same loop variable ($i in the code below) can access the corresponding items in both arrays.
The code above is essentially the same, in a less concise form, as BrowserUk's solution.open my $TEMP, ">", "TMPFILES/$i.tmpfile" or die "cannot open output f +ile $!"; for $i ( 0 .. $#AoA_first ) { print $TEMP "$row_first->[$i]\t$row_second->[$i]\n"; } close $TEMP;
|
|---|