If you just want a specific one, then
jettero's solution is good. If you anticipate many of these lookups, creating a reverse hash may be useful.
my %reverse;
push @{ $reverse{ $sandwichHash{$_} } }, $_ for keys %sandwichHash;
print "@{ $reverse{'burger'} }\n";
print "@{ $reverse{'panini'} }\n";
print "@{ $reverse{'hoagie'} }\n";
My criteria for good software:
- Does it work?
- Can someone else come in, make a change, and be reasonably certain no bugs were introduced?