http://www.perlmonks.org?node_id=1070662


in reply to concatenate scalar with array name

If the arrays have significant differences (they do not have the same meaning, and won't be used the same way), then it's probably better to give them significant names (like "potatoes", "tomatoes", "toes"), in which case a hash can be used (and if the arrays aren't going to be used in the same place, there's no need for having them ordered). Then you can have $hash{potatoes}[0] or $hash{toes}[-1] for exemple.

If the arrays are equivalent sets, in which case the order may be important, then an array of arrays is probably a clearer solution (and faster, but it's not a significant change if there's little data). This means that instead of $array1[0], $array2[3], $array3[9] you would write $array[1][0], $array[2][3] and $array[3][9]. The difference is that you'll have something at index 0 (it can be undef, in which case your first array will be at 1).

Since you seem to be in the second case, here is how to do it:

for my $i (0..4) { for my $j (0..4) { $array[$i][$j] = something($i,$j); } }
Of course what I said still stands, instead of @array, $i, $j and &something, you should use meaningful names.

More info in perldsc