Algorithm::BestChoice is a Perl object similar to a hash, except it returns a result based on a given key AND relative ranking. That is, you can associate multiple values with a single key, and differentiate them by using a rank (or weight).
SYNOPSIS
# Find my favorite food based on color
my $chooser = Algorithm::BestChoice->new;
$chooser->add( match => red, value => cherry, rank => 1 )
$chooser->add( match => red, value => apple, rank => 10 ) # Like apples
$chooser->add( match => red, value => strawberry, rank => -5 ) # Don't like strawberries
$chooser->add( match => purple, value => grape, rank => 20 ) # Delicious
$chooser->add( match => yellow, value => banana )
$chooser->add( match => yellow, value => lemon rank => -5 ) # Too sour
my $favorite;
$favorite = $chooser->best( red ) # apple is the favorite red
$favorite = $chooser->best( [ red, yellow, purple ] ) # grape is the favorite among red, yellow, and purple
Product's homepage
Requirements:
· Perl