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
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 old, the Perl 4 syntax has largely been forgotten. Consequently, the code can be seen as confusing or arcane.
require DBI'SQL'Nano;
Compliant Solution
This compliant solution uses Perl 5's ::
syntax to import an external package:
require DBI::SQL::Nano;
Risk Assessment
Recommendation | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
DCL05-PL | Low | Improbable | Low | P6 | L2 |
Automated Detection
Tool | Diagnostic |
---|---|
Perl::Critic | Variables::ProhibitPerl4PackageNames |
Bibliography
2 Comments
Mike Friedman
The intro to this page seems to be unrelated; also the headings for the code examples are wrong. (They mention Universal::can, which is properly spelled UNIVERSAL::can, but the code examples are not related to UNIVERSAL::can).
Edit: It looks like the intro and headings here are for DCL30-PL.
David Svoboda
Yes they were. Sorry about that; it's been fixed.