> and in any case I wouldn't try to affect a grep or map with those control keywords.

It's documented in next

> "It should not be used to exit a grep or map operation."

Tho it's a bit inconsistent, because return clarifies that those grep/map blocks are special, but doesn't discourage the use.

> Returns from a subroutine, eval, do FILE, sort block or regex eval block (but not a grep, map, or do BLOCK block) with the value given in EXPR.

On a side note: I've never thought of using return inside a sort block and can't remember ever seeing it.

Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery

Update

So I tried it out in the debugger and next inside a grep block is doing exactly what I expected, it's ignoring grep and jumps to the next iteration of the surrounding loop. IOW

perl -de0 DB<12> for (1..9) {say grep {next if $_<5;$_%2} $_..9} 579 79 79 9 9

PS: yes it's a convoluted example.


In reply to Re: Question about loops and breaking out of them properly by LanX
in thread Question about loops and breaking out of them properly by unmatched

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.