Despite Over time, modules in Perl can become obsolete, or superseded by newer modules. Furthermore, despite being over 15 years old, Perl 5 continues to grow. Much of this growth comes from Perl's practice of assimilating popular CPAN modules that prove to be popularinto the core language. Modules that are not part of the core Perl language 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 core language, the original module is still available in CPAN.
Modules that have become obsolete, superseded by newer modules, or integrated into the core language are considered deprecated. but its use is deprecated. Do not import deprecated modules. It is perfectly valid to use their features as they are now
If a module becomes deprecated because its features have been integrated into the core language, then their features may be used without importing the deprecated module.
Here is a list of CPAN modules that are deprecated:should be considered deprecated, according to Perl::Critic.
Deprecated |
---|
|
|
|
|
|
|
|
Noncompliant Code Example (Universal::can()
)
...
Code Block | ||||
---|---|---|---|---|
| ||||
use UNIVERSAL qw(can); # deprecated # ... sub doit { my ($func) = @_; if (can($self, $func)) { $self->$func(); } # ... } |
While Although this code works correctly now, the use
statement will one day not be accepted rejected by the Perl interpreter someday.
Compliant Solution
...
This compliant solution uses Universal::can()
without explicitly importing it.
Code Block | ||||
---|---|---|---|---|
| ||||
# use UNIVERSAL qw(can); # deprecated # rest of code ... sub doit { my ($func) = @_; if ($self->can($func)) { $self->$func(); } # ... } |
Risk Assessment
Using deprecated or obsolete classes or methods in program code can lead to erroneous behavior.
Recommendation | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
DCL30-PL | medium Medium | likely Likely | low Low | P6 P18 | L2 L1 |
Automated Detection
Tool | Version | Checker Diagnostic | Description | ||||
---|---|---|---|---|---|---|---|
Perl::Critic | 5.0 | Modules::ProhibitEvilModules |
| BuiltinFunctions::ProhibitUniversalCan |
| BuiltinFunctions::ProhibitUniversalIsa | Implemented |
B::lint Lint | 5.0 | ... is deprecated and will be removed in a future ... |
Bibliography
...
...
...
...
, |
...
...
, ProhibitUniversalIsa | |
[CPAN] | Ragwitz, Florian, UNIVERSAL |
...
[ProhibitUniversalIsa|http://search.cpan.org/~elliotjs/Perl-Critic-1.116/lib/Perl/Critic/Policy/BuiltinFunctions/ProhibitUniversalIsa.pm] \[[CPAN|AA. Bibliography#CPAN]\] Ragwitz, Florian. [UNIVERSAL|http://search.cpan.org/~flora/perl-5.14.2/lib/UNIVERSAL.pm]EXP11-C. Do not apply operators expecting one type to data of an incompatible type 03. Expressions (EXP) EXP13-C. Treat relational and equality operators as if they were nonassociative