NAME
Getopt::EX::Numbers - module to handle number parameters
SYNOPSIS
use Getopt::EX::Numbers;
my $obj = Getopt::EX::Numbers->new(max => 100);
$obj->parse("start:end:step:length"); $obj->range;
$obj->parse("start:end:step:length")->sequence;
Getopt::EX::Numbers->new->parse("1:10:2")->sequence;
FORMAT
Number format is composed by four elements: start
, end
, step
and length
. All elements are optional.
1 1
1:3 1,2,3
1:20:5 1, 6, 11, 16
1:20:5:3 1,2,3, 6,7,8, 11,12,13, 16,17,18
When start
is omitted, minimum value is used, which is zero by default. If the object is initialized with max
value, end
element can be omitted.
:: all
::2 even numbers
1::2 odd numbers
If start
and end
number is negative, they are subtracted from the maximum number. If the end
number is prefixed by plus (`+') sign, it is summed to start
number. Next examples produce top and last 10 numbers.
:+9 top 10 numbers
-9: last 10 numbers