http://www.perlmonks.org?node_id=395769


in reply to backwards if and while looping

For all of these "why not" people, why not just do:

$a = $b unless $error;

I know it doesn't work correctly if $a > $b. In my defense, some of the other solutions don't either. Anyway,

while ($a < $b) if not $error { $a++; }

looks pretty disgusting if you ask me. Whereas

$a++ while ! $error && $a < $b; if ( ! $error ) { $a++ while $a < $b; } do { $a++ while $a < $b } if ! $error;

all look a bit more elegant. Also

$a++ while not $error || $a >= $b; $a = $b unless $error or $a >= $b;

are cool, IMHO.