Perl has a large number of built-in functions; they are described on the perlfunc
manpage [Wall 2011]. Perl also has a handful of reserved keywords such as while
; they are described on the perlsyn
manpage [Wall 2011].
Do not use an identifier for a subroutine that has been reserved for a built-in function or keywordWhen 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 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
.
Noncompliant Code Example
...
Recommendation | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
DCL04-PL | lowLow | probableProbable | mediumMedium | P2P4 | L3 |
Automated Detection
...
Tool |
| Diagnostic |
|
---|---|---|---|
Perl::Critic | Variables::RequireInitializationForLocalVars |
Bibliography
Bibliography
...
2005] |
...
"Initialization," p. 78 | |
[CPAN] | Elliot Shank, Perl-Critic-1.116 Variables::RequireInitializationForLocalVars |
[Wall 2011] | perlfunc, perlsyn |
...