in reply to Re^6: reading files in @ARGV doesn't return expected output
in thread reading files in @ARGV doesn't return expected output

Oh, would it? So the for loop would open the second series of files as many times as specified in the first series of files?
Yes, if you have nested loops, you would open the files of the second dataset once for each iteration over the first dataset. So, assuming you have five items in your first dataset, you would open 5 times each file of the second dataset.

If you don't believe me, try to run the following code:

for my $i (1..5) { for my $j (1..3) { print "i = $i; j = $j \n"; } }
and observe how many lines you print (should be 15). Each value of $j is printed 5 times. That may be OK is you want to display some combinations (say print out the multiplication tables), but you don't want to open and read each file of the second data set 5 times. And that's even more true if you have more files.

How do you want to combine them for your computations? All of them together? Or pairwise between the two dataset? Like the first matrix from the $i data set with the first one from the $j data set? Or each matrix of the $i data set with each matrix from the $j data set (a kind of Cartesian product)? or something else?

Whichever way, read each file only once and store its content in a separate matrix in memory (say an array of arrays), and make your calculations at a later point. Since you'll have several matrices, you should end up with an AoAoA (array or arrays of arrays) or possibly a HoAoA (hash or arrays of arrays), or some similar data structure, depending on how you want to make the calculations later.