Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Approximate Matching Key

by kilinrax (Deacon)
on Apr 06, 2001 at 22:21 UTC ( [id://70550]=note: print w/replies, xml ) Need Help??


in reply to Approximate Matching Key

How about this?
#!/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; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://70550]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-16 19:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found