in reply to Inverted logic

A will print at the end of the loop if all of the modulo tests come out true.

B will print every time one of the modulo tests come out true during the loop.

What you want is more like:

print "\nLoop 2"; B: for my $a ( 0 .. 9 ) { for my $b ( 2..4 ) { unless( $a % $b ) { next B; } } print $a; }

Replies are listed 'Best First'.
Re^2: Inverted logic
by McA (Priest) on Jul 24, 2013 at 15:27 UTC

    ... I'm getting too slow... ;-)

    I'm pretty sure you updated your answer with the code snippet in a second step, isn't it? :). That would give me some comfort. But anyway: A ++ for being faster...

      Yeah I dropped the explanation first, and then figured it could use a code sample. Failed to check for new posts before submitting; if I'd seen your post I'd have just left mine alone since you said everything I was going to say. Looks like we both made the same code changes at the same time, and ended up with only a 1 character difference :)

      ++ for you too.