in reply to How does one construct and access an array of arrays?
That will let you know if you're actually getting a reference to an array. Watered down, without the object stuff, this code works for me:die "Ack! That's no reference. IT'S A MAN BABY\n" unless(ref $firstR +ow eq "ARRAY);
This looks different than your code in a couple of places. First off (and apologies for the offtopic-ness, but it may simplify your code a bit), since you never use $row, you can simply your for statement to be:use strict; my @AoA; push @AoA, [1..40] for(1..20); print ref $AoA[0]."\n"; print "".(ref $AoA[0])."\n"; print $AoA[0][1]."\n"; Producing (correctly): ARRAY 2
Ahh, a fellow C programmer ;). This is a range, and will be interpreted correctly by the for statement. Pushing the 1..40 or (1..$rows) in array context works fine for making 2d arrays.for(1..$rows)
...it will tell you whether you can use it as an ARRAY. Now if youprint ref $obj->{AoA};
...that will tell you that it's either a SCALAR or (more likely) not a reference (a blank string) in your previous trouble. This means that it can't be dereferenced as an array.print ref $obj->{AoA}[$row];
|
|---|