#!/usr/bin/perl -w use strict; my %data = ( 1 => 'foo', 3 => 'bar', 7 => 'baz', 12 => 'fumble' ); print &find_nearest (10, \%data); sub find_nearest($\%) { my $target = shift; my %data = %{shift()}; while (!defined $data{$target}) { $target--; } return $target; }
In reply to Re: Approximate Matching Key
by kilinrax
in thread Approximate Matching Key
by fxia
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |