Versions Compared

Key

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

Perl 4 used ' as a package name separator when importing packages. Perl 5 provides the same feature but uses :: to separate package names. Use colons rather than single quotation marks to separate packages.

Noncompliant Code Example

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.

...

This noncompliant code example uses the Perl 4 ' syntax to import an external package. This code does successfully require the package, but as but because Perl 5 is over 15 years agoold, the Perl 4 syntax has largely been forgotten. Consequently, the code can be seen as confusing or arcane.

Code Block
bgColor#ffcccc
langperl

require DBI'SQL'Nano;

Compliant Solution

...

This compliant solution uses Perl 5's :: syntax to import an external package:

Code Block
bgColor#ccccff
langperl

require DBI::SQL::Nano;

Risk Assessment

...

Recommendation

Severity

Likelihood

Remediation Cost

Priority

Level

DCL04DCL05-PL

low Low

improbable Improbable

low Low

P3 P6

L1 L2

Automated Detection

Tool

Diagnostic

Perl::Critic

Variables::ProhibitPerl4PackageNames

Bibliography

 

 

...

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