in reply to Approximate Matching Key
my %h = ( 8 => 'value', 3 => 'value', 102 => 'value', 4 => 'value', 1 => 'value', 57 => 'value', ); my @keys = sort { $a <=> $b } keys %h; my $try = shift || 5; # this example allows user to specify on comm +and line my $low = 'not found'; foreach (@keys) { $low = $_ if $_ < $try; last if $_ >= $try; } print "$low\n";
Jeff
R-R-R--R-R-R--R-R-R--R-R-R--R-R-R--
L-L--L-L--L-L--L-L--L-L--L-L--L-L--
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (jeffa) Re: Approximate Matching Key
by baku (Scribe) on Apr 07, 2001 at 00:36 UTC |