In simple and obvious code I agree, but right now I am trying to educate myself so I can work on intricate code without making a mess.

Actually, “intricate” code is a mess, almost by definition! Putting performance to one side for the moment, the best way to avoid writing spaghetti code1 is by keeping things as clear and simple as possible. Structured programming was first proposed precisely for this reason; and the Perl next and last commands violate the (original) structured programming maxim that every loop have only a single entry point and a single exit point.

Does this mean you should avoid next and last when programming Perl? No, they’re too useful — and, when used judiciously, they actually make the programming logic clearer (to a seasoned Perl programmer, anyway). But when nested loops begin to intertwine their control flow, spaghetti code is likely to be the result. And the need for multiple loop labels is a strong warning sign that control flow may have become too complicated.

So, by all means use labels on loops when it makes sense to do so. But please don’t assume that doing so equates to “ease of maintenance” — it may all-too-easily lead to the exact opposite.

1Also called write-only code, since it is unmaintainable.

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,


In reply to Re^7: Radoteur by Athanasius
in thread Radoteur by QuillMeantTen

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.