- or download this
for my $key (keys %hash) {
print "$key\n"
if grep {$_ eq "banana"} @{ $hash{$key} };
}
- or download this
# convert
my %hoh = map {
...
for my $key (keys %hoh) {
print "$key\n" if $hoh{$key}{$search};
}
- or download this
# build inverse hash, if all values are unique
my %inverse_hash;
...
# lookup is simple!
print $inverse_hash{banana}, "\n";
- or download this
# convert to "inverse" hash of arrays (in two steps)
my %hoa;
...
# lookup
print join(', ', @{ $hoa{banana} } ), "\n"