I agree with you about changing entrenched behaviors, and POLA. Oh, well.

I applaud your examples of almost justifiable code. However, I think that these should be refactored to meet POLA as well. IMNSHO, the point of the continue block is to have a landing place for cleanup before restarting the loop, where, for convenience, any number of nexts can expect to go to get the house in order before the next loop. (last and redo don't skip any continue block.)

In the first example, if that code really needs to be in continue for some reason (I realized that process($data); might just be a placeholder for something bigger), then I would rewrite the continue block like so:

continue { do { $data = getSample(); print $logfile "Input contained $data"; } until (not invalid($data)); }

But I would also argue, for serious code, that even this doesn't belong here, and the main loop body needs to be refactored. I guess I'm thinking of a new aphorism, something like:

Don't do anything significant in a continue.

I would approach the second example much the same way, so I leave the details to OMAR.

Anyway, thanks for the debate. Short of getting anything changed, at least I've got it out of my system, even if I end up needing a Ka D'argo-like beating to do so =)

-QM
--
Quantum Mechanics: The dreams stuff is made of


In reply to Re^4: next in continue doesn't DWIM by QM
in thread next in continue doesn't DWIM by QM

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.