There's more than one way to do things | |
PerlMonks |
Re: speeding up a hash lookupby arturo (Vicar) |
on Mar 27, 2001 at 20:50 UTC ( [id://67534]=note: print w/replies, xml ) | Need Help?? |
I'm not sure it would be faster, but you can use the nifty grep operator in conjunction with the keys function to achieve similar effects:
First, you grab the keys within the tolerance range, and then you go through them to nab the greatest value (the ternary operator EXPR ? EXPR1 : EXPR2 returns EXPR1 if EXPR is true, and EXPR2 otherwise). You could, of course, do away with @matching_keys and run the foreach over the grep statement, but that doesn't illustrate the technique as clearly. HTH Philosophy can be made out of anything. Or less -- Jerry A. Fodor
In Section
Seekers of Perl Wisdom
|
|