in reply to Re^3: Short-circuiting a map list. (This works! But ...)
in thread Short-circuiting a map list.

Does that mean uncovered an obscure bug?

Probability is high :)

do does say "do BLOCK" does *not* count as a loop, so the loop control statements "next", "last", or "redo" cannot be used to leave or restart the block. See perlsyn for alternative strategies.

  • Comment on Re^4: Short-circuiting a map list. (This works! But ...)

Replies are listed 'Best First'.
Re^5: Short-circuiting a map list. (This works! But ...)
by BrowserUk (Patriarch) on Oct 08, 2011 at 15:40 UTC
    do does say "do BLOCK" does *not* count as a loop,

    I don't think that is relevant as it is the anonymous block inside the do block that is the target of the last?

    I can also get the same output with the same weirdness whilst avoiding the do block:

    sub b{ my $x = shift; goto sub { { print 'ba'; map { print 'bb'; last if $_ == $x; $_; } @_; print 'bc'; } }; } my @data = 0 .. 9; print for b( 5, @data );

    I am completely at a loss to explain the return values being stacked on top of the passes values?


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

      I don't think that is relevant as it is the anonymous block inside the do block that is the target of the last?

      I am completely at a loss to explain the return values being stacked on top of the passes values?

      Me too , except the aforementioned warning regarding unspecified behavior with loop control structure -- if you can last it, its a loop