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

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

From:
Tony Bowden
Date:
July 18, 2003 11:03
Subject:
Bug #6231: Infinite loop in for/continue/next
Message ID:
20030718180348.GB24048@soto.kasei.com

http://bugs6.perl.org/rt2/Ticket/Display.html?id=6231

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";
		next;
	}

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
such...

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

Tony





nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About