NAME

Number::Rangify - optimize a list of values into ranges

SYNOPSIS

use Number::Rangify 'rangify';

my @list = (1, 2, 3, 5, 7, 9, 10, 11, 15);
my @ranges = rangify(@list);
for my $range (@ranges) {
    printf "%s-%s\n", $range->Size;
}

DESCRIPTION

This module provides a function that can optimize a list of values into range objects.

rangify

Takes a list of values and makes them into ranges.

For example:

rangify(1, 2, 3, 5, 7, 9, 10, 11, 15);

returns the following ranges:

1-3
5-5
7-7
9-11
15-15

It returns a list (in list context) or an array reference (in scalar context) of Set::IntRange objects.

Duplicate values in the input list are ignored.

TAGS

If you talk about this module in blogs, on del.icio.us or anywhere else, please use the numberrangify tag.

BUGS AND LIMITATIONS

No bugs have been reported.

Please report any bugs or feature requests to bug-number-rangify-@rt.cpan.org, or through the web interface at http://rt.cpan.org.

INSTALLATION

See perlmodinstall for information and options on installing Perl modules.

AVAILABILITY

The latest version of this module is available from the Comprehensive Perl Archive Network (CPAN). Visit <http://www.perl.com/CPAN/> to find a CPAN site near you. Or see <http://www.perl.com/CPAN/authors/id/M/MA/MARCEL/>.

AUTHOR

Marcel Grünauer, <marcel@cpan.org>

COPYRIGHT AND LICENSE

Copyright 2007 by Marcel Grünauer

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.