develooper Front page | perl.perl5.porters | Postings from August 2005

[perl #7615] (if|unless) ( local ... ) not undone

Mike Guy
August 26, 2005 09:46
[perl #7615] (if|unless) ( local ... ) not undone
Message ID:
Steve Peters wrote
> This behavior has been fixed in bleadperl by not allowing it.  
> > ./perl
> Can't localize lexical variable $a at line 4.

No it hasn't.    I suspect you did the wrong test  -  what's that
"lexical" doing in the error message?

When I try

perl5.8.6 -w
$a = 10;
if (local $a = 1){
print $a; # Should be 10, not 1
Found = in conditional, should be == at - line 2.

the bug is still present.

I presume this is another manifestation of the fact that a conditional
involves *two* scopes, one including the condition and one not.
Perl conflates them, with unfortunate results.

I presume the resaon for conflating them is efficiency.

Mike Guy Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About