mikez (1) [Avatar] Offline
Dear Andrew,

I have had your book for some time and have found it to be a great help in learning perl. My problem is getting the size of a multidimensional array. Using your example on pages 147 and 148, the array is @twoD = ( [3,7,5], [8,6,1],[4,2,9],) ;

if I use either:
$a = @{$twoD} ;


$b = @twoD ;

the size I get for @twoD is 11. The total number of arrays and elements? I would like to get the size of number of arrays within @twoD which should be two, given that the first array is 0...
Any help with calculating the number of arrays within an array would very useful!

Thank you in advance,
jandrew (10) [Avatar] Offline
Re: size of multidimensional arrays

Sorry for the delay.

I cannot reproduce your claim:

@twoD = ( [3,7,5], [8,6,1], [4,2,9],);
$rows = @twoD;
print "$rows

Which prints 3 (the number of elements in @twoD).