Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
Perl::Critic::Perl::CrUser:ContributedmPerlbDocumentationnimumVersionAndWhy(3)

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

DESCRIPTION
       This 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.

   Disabling
       The 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 Mangling
       Some mangling is	applied	to what	"Perl::MinimumVersion" normally
       reports (as of its version 1.28).

       o   A multi-constant hash with the "constant" module is not reported,
	   since that's	covered	better by Compatibility::ConstantPragmaHash.

       o   Module requirements for things like "use Errno" are dropped,	since
	   you might get a back-port from CPAN etc and the need	for a module
	   is better expressed in a distribution "prereq".

	   But pragma modules like "use	warnings" are still reported.  They're
	   normally an interface to a feature new in the Perl version it comes
	   with	and can't be back-ported.  (See	"OTHER NOTES" below too.)

   MinimumVersion Extras
       The following extra checks are added to "Perl::MinimumVersion".

       5.12 for
	   o   new "keys @array", "values @array" and "each @array"

       5.10 for
	   o   "qr//m",	since "m" modifier doesn't propagate correctly on a
	       "qr" until 5.10

	   o   "-e -f -x" stacked filetest operators.

	   o   "pack()"	new "<"	and ">"	endianness.

	   o   new "UNIVERSAL.pm" method "DOES()"

       5.8 for
	   o   new "word [newline] =>" fat comma quoting across	a newline

	       For earlier Perl	"word" ended up	a function call.  It's
	       presumed	such code is meant to quote in the 5.8 style, and thus
	       requires	5.8 or higher.

	   o   "eval '#line ...'" with "#line" the very	first thing

	       In earlier Perl a "#line" as the	very first thing in an "eval"
	       doesn't take effect.  Adding a blank line so it's not first is
	       enough.

	   o   "pack()"	new "F"	native NV, "D" long double, "i"	IV, "j"	UV,
	       "()" group, "[]"	repeat count

       5.6 for
	   o   new "exists &subr", "exists $array[0]" and "delete $array[0]"

	   o   new "0b110011" binary number literals

	   o   new "open(my $fh,...)" etc auto-creation	of filehandle

	   o   "syswrite()" length parameter optional

	   o   "Foo->$method" no-args call without parens

	       For earlier Perl	a no-args call to a method named in a variable
	       must be "Foo->$method()".  The parens are optional in 5.6 up.

	   o   "pack()"	new "Z"	asciz, "q","Q" quads, "!" native size, "/"
	       counted string, "#" comment

       5.005 for
	   o   new "Foo::Bar::"	double-colon package name quoting

	   o   new "my ($x, undef, $y) = @values", using "undef" as a dummy in
	       a "my" list

       5.004 for
	   o   new "use	5.xxx" Perl version check through "use".  For earlier
	       Perl it can be "BEGIN { require 5.000 }"	etc

	   o   new "__PACKAGE__" special literal

	   o   new "foreach my $foo" lexical loop variable

	   o   new "$coderef->()" call with "->"

	   o   new "sysseek()" builtin function

	   o   "pack()"	new "w"	BER integer

	   o   new "UNIVERSAL.pm" with "VERSION()", "isa()" and	"can()"
	       methods

       "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
       "above_version" (version	string,	default	none)
	   Set a minimum version of Perl you always use, so that reports are
	   only	about things higher than this and higher than what the
	   document declares.  The value is anything the "version.pm" module
	   can parse.

	       [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".

       "skip_checks" (list of check names, default none)
	   Skip	the given MinimumVersion checks	(a space separated list).  The
	   check names are shown in the	violation message and come from
	   "Perl::MinimumVersion::CHECKS".  For	example,

	       [Compatibility::PerlMinimumVersionAndWhy]
	       skip_checks = _some_thing _another_thing

	   This	can be used for	checks you believe are wrong, or where the
	   compatibility matter	only affects limited circumstances which you
	   understand.

	   The check names are likely to be a moving target, especially	the
	   Pulp	additions.  Unknown checks in the list are quietly ignored.

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 "perlA -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/perlA -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 ALSO
       Perl::Critic::Pulp, Perl::Critic

       Perl::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>

COPYRIGHT
       Copyright 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017 Kevin
       Ryde

       Perl-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/>.

perl v5.24.1  Perl::Critic::Policy::Compatibility::PerlMinimumVersionAndWhy(3)

NAME | DESCRIPTION | CONFIGURATION | OTHER NOTES | SEE ALSO | HOME PAGE | COPYRIGHT

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=Perl::Critic::Policy::Compatibility::PerlMinimumVersionAndWhy&sektion=3&manpath=FreeBSD+12.1-RELEASE+and+Ports>

home | help