in reply to Lexical scope variable is not undef'ed
The pad entry for $var is cleared by a directive placed on the stack by my at run-time. Since you never execute the my at run-time, the directive is never created, so $var is never cleared.
The "trick" relies on undocumented internal implementation details, thus its use is discouraged. If you wish to create a "static" variable, then use
{ my $var; sub func { ... } }
(Outer curlies optional.)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Lexical scope variable is not undef'ed
by grinder (Bishop) on Oct 22, 2007 at 17:46 UTC | |
by ikegami (Patriarch) on Oct 22, 2007 at 17:51 UTC |