in reply to Re: Lookup closest hash key
in thread Lookup closest hash key
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 }; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Lookup closest hash key
by choroba (Cardinal) on Oct 09, 2014 at 07:17 UTC |