Kevin Ryde > Perl-Critic-Pulp > Perl::Critic::Policy::Compatibility::PerlMinimumVersionAndWhy

Download:
Perl-Critic-Pulp-23.tar.gz

Dependencies

Annotate this POD

Website

CPAN RT

Open  0
Report a bug
Module Version: 23   Source  

NAME ^

Perl::Critic::Policy::Compatibility::PerlMinimumVersionAndWhy - explicit perl version for features used

DESCRIPTION ^

This policy is part of the Perl::Critic::Pulp addon. It requires that you have an explicit use 5.XXX etc for the Perl syntax features you use as determined by Perl::MinimumVersion. For example,

    use 5.010;       # the // operator is new in perl 5.010
    print $x // $y;  # ok

If you don't have Perl::MinimumVersion then nothing is reported. Certain nasty hacks are used to extract reasons and locations from Perl::MinimumVersion.

This policy is under the "compatibility" theme (see "POLICY THEMES" in Perl::Critic). Its best use is when it picks up things like // or qr only available in a newer Perl than you thought to support.

An explicit use 5.xxx in your code can be tedious, but makes it clear what you need (or think you need) and it gets a good error message if run on an older Perl. The config below lets you limit how far back you might go. Or if you don't care at all about this sort of thing you can always disable the policy completely from you ~/.perlcriticrc file in the usual way,

    [-Compatibility::PerlMinimumVersionAndWhy]

MinimumVersion Mangling

A little mangling is applied to what Perl::MinimumVersion normally reports (as of its version 1.20).

MinimumVersion Extras

The following extra checks are added to what Perl::MinimumVersion normally reports.

CONFIGURATION ^

above_version (version string, default none)

Set a minimum version of Perl you always use, so reports are only about things both higher than this and higher than the document declares. The string is anything version.pm understands. For example,

    [Compatibility::PerlMinimumVersionAndWhy]
    above_version = 5.006

For example if you always use Perl 5.6 and set 5.006 like this then you can have our package variables without an explicit use 5.006.

SEE ALSO ^

Perl::Critic::Pulp, Perl::Critic,

Perl::Critic::Policy::Modules::PerlMinimumVersion is similar, but compares against a Perl version configured in your ~/.perlcriticrc rather than a version in the document.