IfLoop - An extension to the if-elsif-else syntax in Perl.
use IfLoop qw( while until );
IfLoop allows for the creation of if-elsif-else chains that contain loop structures in the if-elsif-else syntax. Just like if-elsif-else chains if-elsifwhile-elsifuntil-else chains can be of arbitrary length and can be nested. Any ifwhile, elsifwhile, etc. syntax can be intermingled with the normal if-elsif-else chains to create combination chains. (See EXAMPLES)
#Use all extensions use IfLoop; # Only use the ifwhile/elseifwhile extension. use IfLoop qw( while ); ifwhile(A) { #code... } else { #code... } # Use both the ifuntil/elseifuntil and ifwhile/elsifwhile extensions. use IfLoop qw( until while ); if(A) { #code... } elsifuntil(B) { #code... } elsifwhile(C) { #code... } else { #code... }
IfLoop actaully just translates its extended syntax into normal Perl syntax. Here are the translations.
ifwhile(A) { #code... }
translates to:
if(A) { do { #code }while(A) } ifuntil(A) { #code... }
if(!(A)) { do { #code }until(A) }
Translation of elsif statments occur in the same way.
Brandon Willis, brandon@silverorb.net
IfLoop's implementation was heavily inspired by Damian Conway's Switch.pm.
Copyright (c) 2003, Brandon Willis. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.
perl.
Initial Release
doc/code clean-up Fixed comment bug.
1 POD Error
The following errors were encountered while parsing the POD:
You forgot a '=back' before '=head1'
To install IfLoop, copy and paste the appropriate command in to your terminal.
cpanm
cpanm IfLoop
CPAN shell
perl -MCPAN -e shell install IfLoop
For more information on module installation, please visit the detailed CPAN module installation guide.