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.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: backwards if and while looping
by Zed_Lopez (Chaplain) on Oct 01, 2004 at 23:18 UTC | |
by !1 (Hermit) on Oct 02, 2004 at 00:28 UTC | |
by Zed_Lopez (Chaplain) on Oct 02, 2004 at 05:27 UTC |
In Section
Seekers of Perl Wisdom