Just in has asked for the wisdom of the Perl Monks concerning the following question:

Is there a way (possibly a module) that is able to look up the most closest numeric key? i.e. given this hash:

my %distances = ( 452 => 'London', 678 => 'Paris', 890 => 'Rome', );

would it be possible to get the value Paris by looking up the non existent key of 672?

I'm able to do this with code that calculates each distance and then sorts the resulting distances. But it just seems a waste to have to calculate each individual distance of the hash for each key that I supply. I assume there's some big O notation that describes this.

Just in