Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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 should be considered deprecated, according to Perl::Critic.

...

Code Block
bgColor#ffcccc
langperl

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
bgColor#ccccff
langperl

# 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 -w

 Implemented

B::Lint

 5.0

... is deprecated and will be removed in a future ...

 

Bibliography

...


 

...

Image Added Image Added Image Removed      01. Declarations and Initialization      Image Modified