
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...
}
translates to:
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.
