Range::Iterator - Generate an iterator object for range
This document describes version 0.002 of Range::Iterator (from Perl distribution Range-Iterator), released on 2019-04-23.
use Range::Iterator; my $iter = Range::Iterator->new(1, 10); while (defined(my $val = $iter->next)) { ... } # 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
You can add step:
my $iter = Range::Iterator->new(1, 10, 2); # 1, 3, 5, 7, 9
You can use alphanumeric strings too since ++ has some extra builtin magic (see perlop):
++
$iter = Range::Iterator->new("zx", "aab"); # zx, zy, zz, aaa, aab
Infinite list:
$iter = Range::Iterator->new(1, Inf); # 1, 2, 3, ...
This module offers an object-based iterator for range.
Usage:
$obj = Range::Iterator->new($start, $end [ , $step ])
my $val = $obj->next
Return the next value, or undef if there is no more values.
Please visit the project's homepage at https://metacpan.org/release/Range-Iterator.
Source repository is at https://github.com/perlancar/perl-Range-Iterator.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Range-Iterator
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
Range::ArrayIter
Array::Iterator & Array::Iter offer iterators for list/array.
perlancar <perlancar@cpan.org>
This software is copyright (c) 2019 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 Range::Iterator, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Range::Iterator
CPAN shell
perl -MCPAN -e shell install Range::Iterator
For more information on module installation, please visit the detailed CPAN module installation guide.