Personally, if I ever find myself wanting to label a loop block, I seriously look into refactoring.

last, next, and redo, have a lot more in common with the hated goto then they do with structured programming.

In some ways they are worse than goto because it takes more effort to find where they are transfering control to (you have to work your way out from nested blocks checking whether each is a loop or not and the editors I use can easily jump to "MyLabel:" but don't have a shortcut for even "jump to top of enclosing loop" (and then to the bottom in case the top is "do {" and we can't tell from that whether we are in a loop or not), much less "jump to top (or bottom) of enclosing Perl loop".

I don't feel too guilty using last, next, and redo sparingly for fairly small loops (I've even experimented with out-denting such lines, but I'm not sure the effect works). I prefer to refactor into a subroutine so I can use return (or, for a complex loop I'll refactor parts into subroutines so that I'm left with a small loop that uses last, next, or redo).

        - tye (but my friends call me "Tye")

In reply to (tye)Re: Test break, but still doing by tye
in thread Test break, but still doing by Coplan

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.