in reply to Re: Grabbing lines three-by-three from a file
in thread Grabbing lines three-by-three from a file

Don't name your loops for no reason.

IMHO, there's nothing wrong with naming your loops, especially (but not only) when there are multiple or nested loops in the general vicinity. It just makes things more clear, and more self-documenting.

  • Comment on Re: Re: Grabbing lines three-by-three from a file

Replies are listed 'Best First'.
Re^3: Grabbing lines three-by-three from a file
by tadman (Prior) on Dec 11, 2001 at 02:21 UTC
    The last function, by definition, bails out of the loop that it is currently inside. If there was any confusion as to where the last call would be tossing program flow to, a comment might help. The loop label indicates the start of the loop, not the finish, so you have to read backwards to find the label, then scan fowards to find the loop finish point.

    Why not this?
    while (something()) { # Lots of stuff, nested functions, etc. last if ($condition); # Move to Post-Processing # Lots more stuff } # Post-Processing more_stuff();
    Instead of:
    PROCESS: while (something()) { # Lots of stuff, nested functions, etc. last PROCESS if ($condition); # Lots more stuff } more_stuff();
    If the while() structure was very long, it might be easier to scan for a carefully worded comment.

    If you have a reason for putting loop labels in, by all means put them in. All I'm advocating is that there shouldn't be things in a program that are there for no reason.

    Or maybe I just don't like Perl programs which feel like:
    _10: print "Hello"; _20: goto _10;