Despite being over 15 years old, Perl 5 continues to grow. Much of this growth comes from Perl's practice of assimilating CPAN modules that prove to be popular. Modules that are not part of Perl must be explicitly included to be used by a program, but modules that are part of the core language need not be.
When a module has been assimilated into the language, the original module is still available in CPAN, but its use is deprecated. Do not import deprecated modules. It is perfectly valid to use their features as they are now integrated into the core language.
Noncompliant Code Example (Universal::can()
)
This noncompliant code example uses the Perl 4 '
syntax to import an external package. This code does successfully require the package, but because Perl 5 is over 15 years ago, the Perl 4 syntax has largely been forgotten. Consequently, the code can be seen as confusing or arcane.
require DBI'SQL'Nano;
Compliant Solution (Universal::can()
)
This compliant solution uses Perl 5's ::
syntax to import an external package:
require DBI::SQL::Nano;
Risk Assessment
Using deprecated or obsolete classes or methods in program code can lead to erroneous behavior.
Recommendation | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
DCL04-PL | low | improbable | low | P3 | L1 |
Automated Detection
Tool | Diagnostic |
Perl::Critic | Variables::ProhibitPerl4PackageNames |
Bibliography
[CPAN] Elliot Shank, Perl-Critic-1.116 Variables::ProhibitPerl4PackageNames