my $nearest_key = nearest(\%hash, $key); { my %nearest; sub nearest { my ($href, $k) = @_; my $low = $k; return $nearest{$k} if exists $nearest{$k}; $low-- until exists $href->{$low}; @nearest{$low .. $k} = ($low) x ($k - $low + 1); return $low; } }
In reply to Re: Approximate Matching Key
by japhy
in thread Approximate Matching Key
by fxia
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |