Coro::Generator - Create generators using Coro
use 5.10.0; # This module does NOT require 5.10, but 'say' does use strict; use Coro::Generator; my $even = generator { my $x = 0; while(1) { $x++; $x++; yield $x; } }; for my $i (1..10) { say $even->(); }
In the words of wikipedia, generators look like functions but act like iterators.
generator, yield
Coro
Brock Wilcox, <awwaiid@thelackthereof.org>
Copyright (C) 2008 by Brock Wilcox
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.
To install Coro::Generator, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Coro::Generator
CPAN shell
perl -MCPAN -e shell install Coro::Generator
For more information on module installation, please visit the detailed CPAN module installation guide.