for my $c ( keys %h ) { my @attr = keys %{$h{$c}}; if ( @attr == 1 and $h{$c}{$attr[0]} == 1 ) { print "$c has a $attr[0]\n"; } . . .