in reply to Hash search and returning by value
If you're going to do that often, and you can't have two cities with the same zip code, you can reverse the hash like this: my %reversed = reverse %zips; and then try exists $reversed{$zip}. Or you can grep on the values instead of the keys: grep { $_ eq $zip } values %zips;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Hash search and returning by value
by Anonymous Monk on Dec 09, 2014 at 16:04 UTC | |
by LanX (Saint) on Dec 09, 2014 at 16:08 UTC | |
by AnomalousMonk (Archbishop) on Dec 09, 2014 at 16:25 UTC |