From: Dave Mitchell Date: Thu, 4 Mar 2004 22:03:17 +0000 (+0000) Subject: Add perldiag entry for change #22435 (deprecate my $x if 0) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4ccc72b7cccd09b4aef23610849d9be0320655b6;p=p5sagit%2Fp5-mst-13.2.git Add perldiag entry for change #22435 (deprecate my $x if 0) p4raw-link: @22435 on //depot/perl: 7921d0f22732c0609e6c9d21be9aaf6e52f99e6b p4raw-id: //depot/perl@22437 --- diff --git a/pod/perldiag.pod b/pod/perldiag.pod index 38be87a..67869a2 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -4282,6 +4282,22 @@ old way has bad side effects. it already went past any symlink you are presumably trying to look for. The operation returned C. Use a filename instead. +=item Deprecated use of my() in false conditional + +(D deprecated) You used a declaration similar to C. +There has been a long-standing bug in Perl that causes a lexical variable +not to be cleared at scope exit when its declaration includes a false +conditional. Some people have exploited this bug to achieve a kind of +static variable. Since we intend to fix this bug, we don't want people +relying on this behavior. You can achieve a similar static effect by +declaring the variable in a separate block outside the function, eg + + sub f { my $x if 0; return $x++ } + +becomes + + { my $x; sub f { return $x++ } } + =item Use of "package" with no arguments is deprecated (D deprecated) You used the C keyword without specifying a package