in reply to exiting a if loop

if is not a looping function, so I don't think you can break out.

Replies are listed 'Best First'.
RE: RE: exiting a if loop
by paulbort (Hermit) on Jun 06, 2000 at 19:18 UTC
    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.
      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!"

RE: RE: exiting a if loop
by lhoward (Vicar) on Jun 06, 2000 at 18:14 UTC
    There is always the dreaded goto function :)

    (I feel dirty even mentioning it)