in reply to Re: The Art of Hashing
in thread The Art of Hashing
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: The Art of Hashing
by shmem (Chancellor) on Jun 16, 2014 at 13:01 UTC | |
|
Re^3: The Art of Hashing
by CountZero (Bishop) on Jun 16, 2014 at 16:49 UTC |