Count of array items from hash with arrays

bt707
bt707 used Ask the Experts™
on
I have hash with array in it that I print out with data::dumper like:

print Dumper($buildingDat);


$VAR1 = {
          'GB' => {
                    'buildings' => [
                                     'Aberdeen_Enterprise Drive Westhill Industrial Estate_GB0010',
                                     'Aberdeen_Kirkton Avenue Pitmedden Road Industrial Estate_GB0015',
                                     'Richmond GB_Parkshort House - Wilson_GB2036'
                                   ]
                  },
          'SY' => {
                    'buildings' => [
                                     'Damascus_17 Nissan Highway Kafarsouseh square_SY0005',
                                     'Deir Ez Zor_Paper Mill Road_SY0010',
                                     'Deir Ez Zor_Omarfield Base_SY0011'
                                   ]
                  },
          'NZ' => {
                    'buildings' => [
                                     'New Plymouth_94 Paraite Bell Block_NZ0005',
                                     'New Plymouth_88-92 Paraite Road - MI SWACO_NZ2010'
                                   ]
                  },
          'HU' => {
                    'buildings' => [
                                     'Szeged_MBRT Yard_HU0015',
                                     'Szolnok_Ka Ra Si UT 43_HU0010'
                                   ]
                  },
          'BD' => {
                    'buildings' => [
                                     'Dhaka_31 Park Road Baridhara_BD0005',
                                     'Dhaka_Apt 502 - MI SWACO Smith_BD2010',
                                     'Dhaka_FR Tower 32 Kemal Ataturk Ave - MI SWACO_BD2011'
                                   ]
                  },
          'UG' => {
                    'buildings' => [
                                     'Kampala_Schlumberger Kampala_UG0001',
                                     'Kampala_Kampala Mbuya Base_UG0002'
                                   ]
                  }
        };


I need to get a count of how many buildings there is from the arrays, not getting the format right.

How can I get a count of all buildings from the building arrays?

Thanks,
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2014
Top Expert 2015
Commented:
my $count=0;
$count += @{$_->{buildings}} for values %{$buildingDat};

Author

Commented:
Thanks ozo, I had that confused.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial