in reply to Approximate Matching Key
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; } }
|
|---|