SPUG: Loop styles: goto vs. redo
Richard Anderson
richard at richard-anderson.org
Tue Jul 2 20:25:04 CDT 2002
----- Original Message -----
From: <dleonard at dleonard.net>
To: <spug-list at pm.org>
Sent: Tuesday, July 02, 2002 2:37 PM
Subject: Re: SPUG: Loop styles: goto vs. redo
>
> Personally I'm more of a fan of while().
>
> my $done = 0;
> while (!$done) {
> for (...) {
> if (...) {
> $done = 1;
> }
> }
> }
>
This repeats UNLESS the conditional evaluates true. This is not equivalent
to the original loop, which repeats IF the conditional evaluates true:
START_TESTS:
my $not_done = 0;
for (...) {
unless (...) {
...
$not_done = 1;
}
}
goto START_TESTS if $not_done
Cheers,
Richard
richard at richard-anderson.org
www.richard-anderson.org
www.raycosoft.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org
More information about the spug-list
mailing list