use TwoWayHash; my %a = get_results_from_query; # assume this populates %a; # then, when you need $b{$a}: { my $b = TwoWayHash->(\%a); print "I need ",$$b{'item'}; ## finds key where $a{key} eq 'item' }