in reply to Exiting the inner loop of a nested loop

Ah, your update definitely makes it more clear. You're not going to be able to accomplish this by printing and checking at the same time. You'll have to do two passes: one to check for any values that you want to avoid, and another to print out all the values from the ones that are deemed ok. Here's a quick example:

my @num_lists = ( [ 0 .. 4 ], [ 5 .. 9 ], [ 10 .. 14 ], [ 15 .. 19 ], ); OUTER: for my $list (@num_lists) { for my $num (@$list) { if ($num % 10 == 0) { print "Skipping $list\n"; next OUTER; } } for my $num (@$list) { print "From $list: $num\n"; } }

Or you can use grep, which still just loops on the values, but might look a bit cleaner to some:

my @num_lists = ( [ 0 .. 4 ], [ 5 .. 9 ], [ 10 .. 14 ], [ 15 .. 19 ], ); for my $list (@num_lists) { next if grep { $_ % 10 == 0 } @$list; for my $num (@$list) { print "From $list: $num\n"; } }