For reason of retro compatibility, and the Principle Of Least Astonishment (well, talk about DWIM ...) when people are used to this behaviour, do not expect this to change. And there might be CPAN modules that rely on this feature, which would go broken if it changed. That's actually the first thing I was told here, because I asked about a possible change of regex syntax (oh foolish me).

Now as for a legitimate use of it ... I never saw one. But I guess it could for exemple be used to separate what should be done on all data samples and what should be only done on "valid data" like:

$data = init(); while(still_alive) { process($data); } continue { $data = getSample(); print $logfile "Input contained $data"; next if invalid($data); }
If process is what is important, and invalid samples are rare enough that you don't want to visually polute the main process, but you still have to deal with them this could a way to do it.

Here is another example:

STATE: until ($state->name eq 'Ending') { $state->action(); redo STATE if nothingHasChanged(); } continue { $state = $state->nextState(context); next STATE unless $blackList->contains($state); #here we want to go +to the next state without processing the current one }


In reply to Re^3: next in continue doesn't DWIM by Eily
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.