last, next, or redo may appear within a continue block; last and redo behave as if they had been executed within the main block. So will next, but since it will execute a continue block, it may be more entertaining.
Just curious if this is really useful, because it can lead to infinite loops that are hard to figure out. Sure, it's pretty obvious that it's an infinite loop, but it's not obvious that next is the cause:
my $try= 0; my $max_tries = 100; while ($try < $max_tries) { last if foo($try); ++$try; } continue { next if ($try % 10); print "Still running after $try tries\n"; }
As soon as ($try % 10) is true, next if ($try % 10) calls itself forever, as $try is never updated after that point. (This could be "solved" by using ($try++ % 10) instead of incrementing in the body, but this only prevents the infinite loop, and the code doesn't behave as intended.)
I would expect that a next from continue would go the the loop body, while a next from the body would go to continue.
Opinions on DWIM?
-QM
--
Quantum Mechanics: The dreams stuff is made of
In reply to next in continue doesn't DWIM by QM
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |