Apr 22, 2014, 10:09 AM
Post #3 of 7
Re: [alferic] array of arrays question
[In reply to]
FishMonger has given you two solutions, but let me complete it with an short explanation on your error.
@AoA = ();
push (@AoA, (@array1,@array2));
As you seem to suspect, yes, indeed, the above code will concatenate the two arrays, i.e. make a single simple array with all the elements of the first array and then all the elements of the second array.
Actually any time you write something like:
you actually obtaining a list of all elements in the first array and then all the element of the second. This also happens if you try to pass two arrays to a subroutine, it does not work because the two arrays get merged into a single one. The solution is to use reference, just the same way FishMonger did.