in reply to Re: Test break, but still doing
in thread Test break, but still doing

If I stuck next; at the end of the if loop, that breaks the if loop, would it not? It's the for loop that I want to break. --Coplan

Replies are listed 'Best First'.
Re: Re: Re: Test break, but still doing
by danger (Priest) on Feb 21, 2001 at 11:37 UTC

    Did you try it? next doesn't apply to if-blocks, it applies to the enclosing loop-block (for or while, or a naked block which is a loop executed once) ... if-blocks are not loops. Similarly for redo and last.

      And if you do have nested loops, you can always break out of the one that you want by using labels...
      LAB_1:
        while ([cond1]) {
      
      LAB_2:
          while ([cond2]) {
            next LAB_1 if [cond3];
          }
        }
      
      As archon says, its all there in the perlsyn page.