in reply to Re: "last" not really outside loop block
in thread "last" not really outside loop block

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

Replies are listed 'Best First'.
Re^3: "last" not really outside loop block
by ikegami (Patriarch) on Jun 22, 2009 at 17:01 UTC
    You parsed it correct. BrowserUk made the last behave like a next.
Re^3: "last" not really outside loop block
by BrowserUk (Patriarch) on Jun 22, 2009 at 17:02 UTC

    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.