develooper Front page | perl.perl5.porters | Postings from December 2004

[perl #2215] redo undefines variables declared like while (my $i ...) { redo; }

From:
Steve Peters via RT
Date:
December 8, 2004 11:06
Subject:
[perl #2215] redo undefines variables declared like while (my $i ...) { redo; }
Message ID:
rt-3.0.11-2215-102418.0.434524516185846@perl.org
> [yves.orton@de.mci.com - Wed Dec 08 11:02:33 2004]:
> 
> Dave Mitchell wrote:
> > > If your interpretation of this is correct then I think the
documentation
> > > should be changed to clarify the point. I wouldn't have expected this
> result
> > > from that description. In fact that description makes me think that
> > > 
> > >   my @a=(2..5);
> > >   while (my $x=shift @a) {
> > >       print $x,"\n";
> > >       redo if $x--;
> > >    }
> > > 
> > > and
> > > 
> > >   my @a=(2..5);
> > >   while (my $x=shift @a) {
> > > 	STARTBLOCK:
> > >       print $x,"\n";
> > >       goto STARTBLOCK if $x--;
> > >    }
> > > 
> > > should be equivelent, but by your reading they aren't.
> > 
> > I'm with Yves on this one.
> 
> It occurred to me that there is another reason to not agree with the
> proposed interpretation. It means that redo in for loops and while
loops do
> different things:
> 
>   my @a=(2..5);
>   for my $x (@a) {
>     print $x,"\n";
>     redo if $x--;
>   }
> 
> In this case the $x doesn't suddenly become undef after the redo.... 
> 
> IMO the reported bug is indeed a bug. 
> 

Reopened :)



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