You need to iterate over the top-level array, and then work on each element individually. Here's an example:
use warnings; use strict; my @aoa = ( [qw(1 1 1 1)], [qw(2 2 2)], 'a string', [qw(3 3 3 3 3 3 3)], {a => 1, b => 2}, ); my $index = 0; for (@aoa){ if (ref $_ eq 'ARRAY'){ my $element_count = scalar @$_; print "elem $index has $element_count elements\n"; } else { print "elem $index is not an array reference\n"; } $index++; }
Output:
elem 0 has 4 elements elem 1 has 3 elements elem 2 is not an array reference elem 3 has 7 elements elem 4 is not an array reference
In reply to Re: Find number of items in a field multi-demensional array
by stevieb
in thread Find number of items in a field of a multi-demensional array
by msnyder424
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |