If you stick the count variables in a hash you can reduce the loop code a bit. Not sure if this is any faster or more efficient. You have to define the count structure up front as well.
my $count =
{
"Menu" => {
"Count" => 0,
"Voice" => 0,
"NoVoice" => 0},
"Video" => {
"Count" => 0,
"Voice" => 0,
"NoVoice" => 0}
};
foreach my $entry (values(%$file))
{
$count->{$entry->{FILETYPE}}->{"Count"}++;
if($entry->{VOICEOVER} eq "No")
{ $count->{$entry->{FILETYPE}}->{"NoVoice"}++ }
else
{ $count->{$entry->{FILETYPE}}->{"Voice"}++ }
}
# Example getting one of the counts out.
print $count->{"Menu"}->{"Count"} . "\n";
When I started this I thought it would come out smaller than this. Thought someone might find it useful or make it a bit smaller.