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

No deprecation warning for my $zam = "clunk_eth" if 0;

Thread Next
From:
Steve Peters
Date:
December 23, 2011 12:56
Subject:
No deprecation warning for my $zam = "clunk_eth" if 0;
Message ID:
CAP0GdH34UupBh2+MKxtO3tVZmJm9oJu7DodzAZjTg5tUYXN9rw@mail.gmail.com
I've gone through several old mailing list posts so maybe I've missed the
reasoning here, but back in March 2004 code was added for the following
case..

$ perl -wle'my $zam if 0'
Deprecated use of my() in false conditional at -e line 1.

I've strained my brain to see if I remember a reason for this case to warn
while a case where an assignment is done does not warn.  For example...

$ perl -wle'my $zam = "clunk_eth" if 0'

Both, however, have identical behavior.

$ perl -wle'sub kapow { my $zam if 0; $zam++ } print kapow(); print
kapow(); print kapow();'
Deprecated use of my() in false conditional at -e line 1.
0
1
2

$ perl -wle'sub kapow { my $zam = "clunk_eth" if 0; $zam++ } print kapow();
print kapow(); print kapow();'
0
1
2

Steve Peters
steve@fisharerojo.org

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