On Mon, Jun 7, 2010 at 5:27 PM, perl@profvince.com < perlbug-followup@perl.org> wrote: > # New Ticket Created by perl@profvince.com > # Please include the string: [perl #75596] > # in the subject line of all future correspondence about this issue. > # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=75596 > > > > This is a bug report for perl from perl@profvince.com, > generated with the help of perlbug 1.39 running under perl 5.10.1. > > > ----------------------------------------------------------------- > [Please describe your issue here] > > Perl doesn't reset the array iterator when the array is cleared : > > $ perl5.12.1-64 -M5.012 -E 'my @a = "a" .. "c"; my ($i, $v) = each @a; > say "$i: $v"; @a = "A" .. "C"; ($i, $v) = each @a; say "$i: $v"' > 0: a > 1: B > The iterator can be reset by calling keys(). This is efficient in void context. $ perl -E' my @a = "a".."c"; for (1..2) { my ($i,$v) = each @a; say "$i: $v"; @a = "A".."C"; } ' 0: a 1: B $ perl -E' my @a = "a".."c"; for (1..2) { keys @a; my ($i,$v) = each @a; say "$i: $v"; @a = "A".."C"; } ' 0: a 0: AThread Previous | Thread Next