NAME
Range::Iterator - Generate an iterator object for range
VERSION
This document describes version 0.002 of Range::Iterator (from Perl distribution Range-Iterator), released on 2019-04-23.
SYNOPSIS
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, ...
DESCRIPTION
This module offers an object-based iterator for range.
METHODS
new
Usage:
$obj = Range::Iterator->new($start, $end [ , $step ])
next
Usage:
my $val = $obj->next
Return the next value, or undef if there is no more values.
HOMEPAGE
Please visit the project's homepage at https://metacpan.org/release/Range-Iterator.
SOURCE
Source repository is at https://github.com/perlancar/perl-Range-Iterator.
BUGS
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.
SEE ALSO
Array::Iterator & Array::Iter offer iterators for list/array.
AUTHOR
perlancar <perlancar@cpan.org>
COPYRIGHT AND LICENSE
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.