SPUG: Loop styles: goto vs. redo

Richard Anderson richard at richard-anderson.org
Mon Jul 1 23:10:07 CDT 2002


After some wrangling with my CPAN co-author over a trivial point of style,
I'd like to throw this before the group.  For production code, which is
better (or suggest an alternative that is better than both):

START_TESTS:
    my $not_done = 0;
    for (...) {
        unless (...) {
            ...
            $not_done = 1;
        }
    }
    goto START_TESTS if $not_done

or

{
    my $done = 1;
    for  (....) {
        unless(...) {
            ...
            $done = 0;
        }
    }
    redo unless $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