$c = 0; for (keys %hash) { $c++ if $hash{$_}{'x'} && !$hash{$_}{'y'}; } print "$c\n"; $c = 0; for (keys %hash) { $c++ if $hash{$_}{'z'}; } print "$c\n"; $c = 0; for (keys %hash) { $c++ if $hash{$_}{'z'} == 101; } print "$c\n";