#!/usr/bin/env perl use strict; use warnings; my %counts = ( Status => { 0 => 99, 1 => 12, 2 => 3, 77 => 4 } # Other keys would go here ); my $totalfails = 0; $totalfails += $counts{Status}{$_} for grep {$_ > 1} keys %{$counts{Status}}; print "Total failures: $totalfails\n";