Any normal use of goto can be replaced by an entirely equivalent loop control statement, possibly using labels when breaking out of multiple levels of loops.
This is exactly why in some cases I prefer goto over loop control statements. A loop introduces a block. Variabled my()ed in the block don't live outside them - if they are needed after the block (or goto destination), you have to separate the my() and the first initialization. Which is something I prefer not to. Second, sometimes you encounter code that, if turned into nested loops instead of gotos, will be nested deeply. Which can lead to a narrow strip of code on the right hand side of the window.

Now, that doesn't mean I use goto lightly. But I may opt for a goto instead of loop control two or three times a year.


In reply to Re^4: GOTO or not GOTO by JavaFan
in thread GOTO or not GOTO by jflevi

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.