Range::Serial - Implements ranges of integer identificators
use Range::Serial; # Create a new range my $range = Range::Serial->new('1-10, 12, 15', 17..20); # Test if a value is in range print "in range\n" if $range->in(5); print "not in range\n" if !$range->in(11); # Add values to range $range->add(11, '13-14;16'); # Get full list of values my @list = $range->range(); print join q{ }, @list; # Prints 1 2 3 4 5 ... 20 # Get collapsed string representation my $string = $range->range(); print "$string\n"; # Prints '1-20' # Get range size my $size = $range->size(); print "$size"; # Prints: 20
This module implements ranges of positive integer numbers that can be used as object identifiers.
See Range::Object.
Only positive integer numbers are supported. No backward ranges are supported, i.e. while '1-10' is valid range, '10-1' is not.
There are no known bugs in this module. Please report problems to author, patches are welcome.
Alexander Tokarev <tokarev@cpan.org>.
Copyright (c) 2011 Alexander Tokarev.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
To install Range::Object, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Range::Object
CPAN shell
perl -MCPAN -e shell install Range::Object
For more information on module installation, please visit the detailed CPAN module installation guide.