Tie::NumericRange - Perl extension that creates key / value pairs out of numeric ranges!
use Tie::NumericRange; my %h; tie (%h, Tie::NumericRange); $h{'2.90..9.65'} = "Some value for this fab range!"; print $h{'3'} . "\n"; # prints "Some value for this fab range!\n" print $h{'4.621235'} . "\n"; # same print $h{'10.1235'} . "\n"; # prints undef . "\n" delete($h{'4'}); print $h{'4'} . "\n"; # prints undef . "\n" print $h{'4.1'} . "\n"; # prints "Some value for this fab range!\n" keys(%h) #.. all the numbers in the ranges defined
Tie::NumericRange creates a hash that takes numeric ranges as its keys. You can then reference the value assigned to the range using a member of that range.
Number::Range which does similar things, supports similar formats, but does not support floats and uses an object / method interface instead of a hash interface.
Michael Gregorowicz, <mike@mg2.org>
Copyright (C) 2008 by Michael Gregorowicz
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.
To install Tie::NumericRange, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tie::NumericRange
CPAN shell
perl -MCPAN -e shell install Tie::NumericRange
For more information on module installation, please visit the detailed CPAN module installation guide.