1. For perl hashes, the only way to get matching keys of a hash for a given string, is performing a pattern match on the entire set of keys.my @matching_keys = grep /$customer/, keys %Customer;
As some guy who used to be famous around here once said: "that's like buying and Uzi and using it to club your enemy to death".
It's also very misleading because the hash is serving no useful purpose in that construct.
It would be considerably cheaper to put the list of keys into an array and grep that than force Perl to re-walk the hash structure to generate the list of strings for grep each time around.
In reply to Re^2: The Art of Hashing
by BrowserUk
in thread The Art of Hashing
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |