When a package variable is declared local
, it is often assumed that the package variable's contents are duplicated and stored in the local variable. This is not so; the local variable is set to undef
, just like any other unitialized uninitialized variable. Consequently, local variables must be initialized. They may be initialized with the contents of the package variable. If they are meant to be uninitialized, they should be explicitly set to undef
.
...
Recommendation | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
DCL04-PL | Low | Probable | Medium | P4 | L3 |
Automated Detection
...
Tool | Diagnostic | ||
---|---|---|---|
Perl::Critic | Variables::RequireInitializationForLocalVars |
Bibliography
...
...
"Initialization," p. 78 | |
[CPAN] | Elliot Shank, Perl-Critic-1.116 Variables::RequireInitializationForLocalVars |
[Wall 2011] | perlfunc, perlsyn |
...