in reply to "last" not really outside loop block

I don't see much value in the construct, but you can achieve your goal by adding a bare block:

do{{ last unless $a==4 }} while 1;

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.
RIP PCW

Replies are listed 'Best First'.
Re^2: "last" not really outside loop block
by Limbic~Region (Chancellor) on Jun 22, 2009 at 16:43 UTC
    BrowserUk,
    I am parsing with my brain and not perl but something is telling me that should instead be:
    { my $a = 3; do { last unless $a == 4; } while 1; }

    The difference being that you would be escaping the block and the loop. In my brain's parsing of your version, I last outside of the loop which is still inside the block and then re-enter because of the post-fix while condition.

    Cheers - L~R

      You parsed it correct. BrowserUk made the last behave like a next.

      Right you are.

      Adding a bare block allows the use of the loop constructs, next, last & redo ansd works as expected most places, but not in this case.


      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.