IntRange::Iter - Generate a coderef iterator from an int range specification (e.g. '1,5-10,20')
This document describes version 0.005 of IntRange::Iter (from Perl distribution IntRange-Iter), released on 2021-07-25.
use IntRange::Iter qw(intrange_iter); my $iter = intrange_iter('1,5-10,15-17'); # or: intrange_iter({allow_dotdot=>1}, '1,5-10,15..17'); while (my $val = $iter->()) { ... } # 1, 5,6,7,8,9,10, 15,16,17 undef, ...
This module provides a simple (coderef) iterator which you can call repeatedly to get numbers specified in an integer range specification (string). When the numbers are exhausted, the coderef will return undef. No class/object involved.
Usage:
$iter = intrange_iter([ \%opts ], $spec); # coderef
Options:
allow_dash
Bool. Default true. At least one of allow_dash or "allow_dotdot" must be true.
allow_dotdot
Bool. Default false. At least one of "allow_dash" or allow_dotdot must be true.
Please visit the project's homepage at https://metacpan.org/release/IntRange-Iter.
Source repository is at https://github.com/perlancar/perl-IntRange-Iter.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=IntRange-Iter
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
Range::Iter
NumSeq::Iter
Modules that might also interest you: Set::IntSpan and Array::IntSpan.
perlancar <perlancar@cpan.org>
This software is copyright (c) 2021 by perlancar@cpan.org.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install IntRange::Iter, copy and paste the appropriate command in to your terminal.
cpanm
cpanm IntRange::Iter
CPAN shell
perl -MCPAN -e shell install IntRange::Iter
For more information on module installation, please visit the detailed CPAN module installation guide.