![]() |
![]()
| ![]() |
![]()
NAMEPerl::Critic::Policy::Compatibility::PerlMinimumVersionAndWhy - explicit Perl version for features usedDESCRIPTIONThis policy is part of the "Perl::Critic::Pulp" add-on. It requires that you have an explicit "use 5.XXX" etc for the Perl syntax features you use, as determined by "Perl::MinimumVersion".use 5.010; # the // operator is new in perl 5.010 print $x // $y; # ok If you don't have the "Perl::MinimumVersion" module 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" which are only available in a newer Perl than you meant to target. An explicit "use 5.xxx" can be a little tedious, but has the advantage of making it clear what's needed (or supposed to be needed) and it gives a good error message if run on an older Perl. DisablingThe config options below let you limit how far back to go. Or if you don't care at all about this sort of thing you can always disable the policy completely from your ~/.perlcriticrc file in the usual way (see "CONFIGURATION" in Perl::Critic),[-Compatibility::PerlMinimumVersionAndWhy] MinimumVersion ManglingSome mangling is applied to what "Perl::MinimumVersion" normally reports (as of its version 1.28).
MinimumVersion ExtrasThe following extra checks are added to "Perl::MinimumVersion".
"pack()" and "unpack()" format strings are only checked if they're literal strings or here-documents without interpolations, or "." operator concats of those. The "qr//m" report concerns a misfeature fixed in perl 5.10.0 (see perl5101delta). In earlier versions a regexp like "$re = qr/^x/m" within another regexp like "/zz|$re/" loses the "/m" attribute from $re, changing the interpretation of the "^" (and "$" similarly). Forms like "(\A|\n)" are a possible workaround, though are uncommon so may be a little obscure. "RegularExpressions::RequireLineBoundaryMatching" asks for "/m" in all cases so if think you want that then you probably want Perl 5.10 or up for the fix too. "Modern::Perl""use Modern::Perl" is taken to mean Perl 5.10. This is slightly experimental and in principle the actual minimum it implies is forever rising, and even now could be more, or depends on it date argument scheme. Maybe if could say its actual current desire then an installed version could be queried.CONFIGURATION
OTHER NOTES"use warnings" is reported as a Perl 5.6 feature since the lexically-scoped fine grain warnings control it gives is new in that version. If targeting earlier versions then it's often enough to drop "use warnings", ensure your code runs cleanly under "perl -w", and leave it to applications to use "-w" (or set $^W) if they desire."warnings::compat" offers a "use warnings" for earlier Perl, but it's not lexical, instead setting $^W globally. In a script this might be an alternative to "#!/usr/bin/perl -w" (per perlrun), but in a module it's probably not a good idea to change global settings. The "UNIVERSAL.pm" methods "VERSION()", "isa()", "can()" or "DOES()" might in principle be implemented explicitly by a particular class, but it's assumed that's not so and that any call to those requires the respective minimum Perl version. SEE ALSOPerl::Critic::Pulp, Perl::CriticPerl::Critic::Policy::Modules::PerlMinimumVersion, which is similar, but compares against a Perl version configured in your ~/.perlcriticrc rather than a version in the document. Perl::Critic::Policy::Modules::RequirePerlVersion HOME PAGE<http://user42.tuxfamily.org/perl-critic-pulp/index.html>COPYRIGHTCopyright 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2019, 2021 Kevin RydePerl-Critic-Pulp is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. Perl-Critic-Pulp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Perl-Critic-Pulp. If not, see <http://www.gnu.org/licenses/>.
|