%h = (a=>"A", "b"=>"B", "bb" => "B"); for ( keys %h ) { print $_ if $h{$_} eq "B"; }