OUTER: foreach my $i ( $from .. $to ) { $i % $_ and next OUTER for 2 .. 5; say $i; }