in reply to Paranormal leakage of previous value from conditionally set lexical variable
NOTE: The behaviour of a my, state, or our modified with a statement modifier conditional or loop construct (for example, my $x if ...) is undefined. The value of the my variable may be undef, any previously assigned value, or possibly anything else. Don't rely on it. Future versions of perl might do something different from the version of perl you try it out on. Here be dragons.
$ perl -Mdiagnostics -wMstrict -le 'my $x if 0' Deprecated use of my() in false conditional at -e line 1 (#1) (D deprecated) You used a declaration similar to my $x if 0. 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. ...
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Paranormal leakage of previous value from conditionally set lexical variable
by Anonymous Monk on Mar 09, 2016 at 19:53 UTC | |
by stevieb (Canon) on Mar 09, 2016 at 19:58 UTC |