develooper Front page | perl.perl5.porters | Postings from June 2010

Re: [perl #75596] Iterator not reset on array assignment

Thread Previous
From:
Abigail
Date:
June 8, 2010 04:49
Subject:
Re: [perl #75596] Iterator not reset on array assignment
Message ID:
20100608114955.GA22742@almanda
On Mon, Jun 07, 2010 at 02:27:33PM -0700, perl@profvince.com 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 issue is still present in 5.13.1.


Interesting. My first reaction was, "it probably should reset the iterator".
But then I wondered, what if one had written C<< $a [1] = "B" >> instead of
C<< @a = "A" .. "C" >>? Should the iterator be reset then? What on
C<< @a [0 .. 2] = "A" .. "C" >>? Should shift, pop, push, unshift, splice
reset the iterator? Currently none of them do.

Even C<< undef @a; @a = "A" .. "C"; >> doesn't reset the iterator.


Abigail

Thread Previous


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