in reply to How cand I find each dimension x,y,z of a 3D arrays
Arrays in Perl don't have fixed dimensions. If you have a 2D array (actually an array of references to arrays), it is quite possible that each second level array has a different number of elements.
Here is some code to print the number of elements in each second level array in such a data structure. The concept is easily extendable to three dimensions.
my @AoA = (['the', 'first', 'array'], ['another', 'array'], ['this', 'is', 'the', 'last', 'one']); foreach (@AoA) { print scalar @$_, " elements\n"; }
This prints out:
3 elements 2 elements 5 elements
Originally posted as a Categorized Answer.
|
|---|