It's actually easier than you're making it:
use warnings; use strict; use Data::Dumper; my %hash = ( 'ScreenName1.Description1' => { 'ScreenName' => 'A', 'Description' => 'A Description of this button', 'Type' => 'On/Off' }, 'ScreenName2.Description2' => { 'ScreenName' => 'B', 'Description' => 'A Description of this button', 'Type' => 'Momentary' }, 'ScreenName3.Description3' => { 'ScreenName' => 'A', 'Description' => 'A Description of this button', 'Type' => 'Momentary' }, 'ScreenName4.Description4' => { 'ScreenName' => 'A', 'Description' => 'A Description of this button', 'Type' => 'On/Off' }, 'ScreenName5.Description5' => { 'ScreenName' => 'B', 'Description' => 'A Description of this button', 'Type' => 'On/Off' }, ); my %ScreenNameCount; $ScreenNameCount{$hash{$_}{ScreenName}}++ foreach keys %hash; print Dumper \%ScreenNameCount;
This outputs:
$VAR1 = { 'A' => 3, 'B' => 2 };
Dave
In reply to Re: counting occurrence of an element in a hash
by davido
in thread counting occurrence of an element in a hash
by JusaEngineer
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |