Number::Closest - Find number(s) closest to a number in a list of numbers
use Number::Closest; my $finder = Number::Closest->new(number => $num, numbers => \@num) ; my $closest = $finder->find; # finds closest number my $closest_two = $finder->find(2) ; # gives arrayref of two closest numbers in list # or, all in one shot Number::Closest->new(number => $num, numbers => \@num)->find(1) ;
http://stackoverflow.com/questions/445782/finding-closest-match-in-collection-of-numbers
Currently maintained by Mike Accardo, <accardo@cpan.org>
Original author Terrence Monroe Brannon.
Copyright (c) 2015 Mike Accardo Copyright (c) 1999-2014 Terrence Brannon
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Number::Closest, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Number::Closest
CPAN shell
perl -MCPAN -e shell install Number::Closest
For more information on module installation, please visit the detailed CPAN module installation guide.