in reply to RE: exiting a if loop
in thread exiting a if loop

Sure you can. Check the last para in the doc:
Note that a block by itself is semantically identical to a loop that executes once. Thus `last' can be used to effect an early exit out of such a block.

Replies are listed 'Best First'.
RE (3) paulbort: exiting a if loop
by nuance (Hermit) on Jun 06, 2000 at 20:24 UTC
    An "if block" is not considered a looping construct on it's own, it's an exception, so the loop exit statements don't work. What you can do is make the "if block" contain just a "bare block". Since a bare block is considered a loop then it works, so:
    if (true) { yada; yada; next if $foo; yada; yada; }
    Doesn't work,
    if (true) { { yada; yada; next if $foo; yada; yada; } # next comes here }
    Does.

    Nuance

    Baldrick, you wouldn't see a subtle plan if it painted itself purple and danced naked on top of a harpsichord, singing "Subtle plans are here again!"