develooper Front page | perl.perl5.porters | Postings from July 2003

Bug #6231: Infinite loop in for/continue/next

Tony Bowden
July 18, 2003 11:03
Bug #6231: Infinite loop in for/continue/next
Message ID:

The reported bug (which was commented a couple of weeks ago as still
appearing in 5.8) is basically that:

	for my $i (0 .. 2) {
		print "$i\n";
	} continue {
		print "$i\n";

loops forever.

However, 'continue' is documented such:

	"last", "next", or "redo" may appear within a "continue" block.  "last"
	and "redo" will 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.

This implies that this isn't therefore a bug, and should be marked as

Although perhaps the documentation should be made a tad more explicit
than just "may be more entertaining"?

Tony Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About