Acme::Loopy - loop keyword
loop { my @row = get_data() or last; # First iteration only print table_headers(\@row) unless ${^LOOP}; # All iterations print table_row(\@row); }
This is really just a test/experiment with Keyword::Simple. It gives you a keyword loop which acts like a while(1) loop - that is, it loops infinitely until an explicit last. This is quite similar to ikegami's Syntax::Feature::Loop.
loop
while(1)
last
Within the loop, the variable ${^LOOP} can be used to obtain the current iteration count. This is a zero-based count, so is zero (false) on the first journey around the loop.
${^LOOP}
Keyword::Simple made defining the loop keyword itself so easy that ${^LOOP} became the tricky part. (Or rather making it work with nested loops did!)
Please report any bugs to http://rt.cpan.org/Dist/Display.html?Queue=Acme-Loopy.
Keyword::Simple, Syntax::Feature::Loop.
Toby Inkster <tobyink@cpan.org>.
This software is copyright (c) 2012 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
To install Acme::Loopy, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Acme::Loopy
CPAN shell
perl -MCPAN -e shell install Acme::Loopy
For more information on module installation, please visit the detailed CPAN module installation guide.