[sf-perl] Opinions on: next LABEL;

Chris Palmer chris at noncombatant.org
Wed May 11 11:48:58 PDT 2005

David Alban writes:

> Way back when, I learned that "goto" was a four letter word in
> structured programming.

And now we have exceptions, which are basically the same thing, yet they
are considered "hip" and "with it". Oh well. :) I consider goto rarely,
but definitely sometimes, necessary.

>   FOO:
>   for ( ... ) {
>     for ( ... ) {
>        ...some condition... and next FOO;
>     } # for
>   } # for

This seems reasonable. However, if these for loops together total more
than (say) 2 80x24 screensful, breaking things into smaller subroutines
might be a good idea. The key to the above code being okay is its
brevity -- if the reader can see the whole thing in one glance, that's
goodness, even if there are some kinks like "next FOO".

The labels can be documentation, actually contributing to increased

LINE: while ($ln = <>) {
    WORD: for $wrd (split /\s+/, $ln) {
        next LINE if $wrd =~ /^#/;

More information about the SanFrancisco-pm mailing list