in reply to Oddly growing array

To expand on Roy Johnson's comment, you are iterating one past the end of your array each time, and autovivifying the new elements. Here's a quick demonstration:

my @array = ( [ 1, 2, 3 ], [ 4, 5, 6 ], ); print scalar(@array), "\n"; # 2 print $array[2][0], "\n"; # undef print scalar(@array), "\n"; # 3

You can see the new element is automatically added by just accessing a subelement.