develooper Front page | perl.perl5.porters | Postings from March 2013

Re: Infinite loop in for (@a) { push @a, $_ }

Thread Previous | Thread Next
From:
Zefram
Date:
March 19, 2013 12:02
Subject:
Re: Infinite loop in for (@a) { push @a, $_ }
Message ID:
20130319120154.GR20429@lake.fysh.org
demerphq wrote:
>Seems to me we just* have to remember the size of the array when we
>start the for() loop and only iterate to that size.

That only works if the only array modification in the loop is to add
new elements on the end.  Fails if the array is shortened, or spliced,
or if element aliasing changes.

-zefram

Thread Previous | Thread Next


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