Otherwise this is a great trick, thanks!sub nearest{ my ( $dist, $href ) = @_; my ( $answer ) = ( sort { abs( $a - $dist ) <=> abs( $b - $dist ) +} keys %$href )[0]; return $href -> { $answer }; }
In reply to Re^2: Lookup closest hash key
by Anonymous Monk
in thread Lookup closest hash key
by Just in
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |