Perl::Critic::Policy::Freenode::DeprecatedFeatures - Avoid features that have been deprecated or removed from Perl
While Perl::Critic::Policy::Freenode::StrictWarnings will expose usage of deprecated or removed features when a modern perl is used, this policy will detect such features in use regardless of perl version, to assist in keeping your code modern and forward-compatible.
Because the whitespace between an attribute list and assignment operator is not significant, it was possible to specify assignment to a variable with an empty attribute list with a construction like my $foo := 'bar'. This is deprecated in perl v5.12.0 to allow the possibility of a future := operator. Avoid the issue by either putting whitespace between the : and = characters or simply omitting the empty attribute list.
my $foo := 'bar'
:=
:
=
The magic "$[" in perlvar variable was used in very old perls to determine the index of the first element of arrays or the first character in substrings, and also allow modifying this value. It was discouraged from the start of Perl 5, its functionality changed in v5.10.0, deprecated in v5.12.0, re-implemented as arybase.pm in v5.16.0, and it is essentially a synonym for 0 under use v5.16 or no feature "array_base". While it is probably a bad idea in general, the modules Array::Base and String::Base can now be used to replace this functionality.
0
use v5.16
no feature "array_base"
The ?PATTERN? regex match syntax is deprecated in perl v5.14.0 and removed in perl v5.22.0. Use m?PATTERN? instead.
?PATTERN?
m?PATTERN?
An experimental feature was introduced in perl v5.14.0 to allow calling various builtin functions (which operate on arrays or hashes) on a reference, which would automatically dereference the operand. This led to ambiguity when passed objects that overload both array and hash dereferencing, and so was removed in perl v5.24.0. Instead, explicitly dereference the reference when calling these functions. The functions affected are each, keys, pop, push, shift, splice, unshift, and values.
each
keys
pop
push
shift
splice
unshift
values
Using the function defined() on an array or hash probably does not do what you expected, and is deprecated in perl v5.6.2 and throws a fatal error in perl v5.22.0. To check if an array or hash is non-empty, test if it has elements.
defined()
if (@foo) { ... } if (keys %bar) { ... }
This form of do to call a subroutine has been deprecated since perl 5, and is removed in perl v5.20.0.
do
Use of the "no-break space" character in character names is deprecated in perl v5.22.0 and an error in perl v5.26.0.
Several character matching functions in POSIX.pm are deprecated in perl v5.20.0. See the POSIX documentation for more details. Most uses of these functions can be replaced with appropriate regex matches.
isalnum, isalpha, iscntrl, isdigit, isgraph, islower, isprint, ispunct, isspace, issuper, isxdigit
The tmpnam() function from POSIX.pm is deprecated in perl v5.22.0 and removed in perl v5.26.0. Use File::Temp instead.
tmpnam()
Literal parentheses are required for certain statements such as a for my $foo (...) { ... } construct. Using a qw(...) list literal without surrounding parentheses in this syntax is deprecated in perl v5.14.0 and a syntax error in perl v5.18.0. Wrap the literal in parentheses: for my $foo (qw(...)) { ... }.
for my $foo (...) { ... }
qw(...)
for my $foo (qw(...)) { ... }
A bareword require (or use) starting with a double colon would inadvertently translate to a path starting with /. Starting in perl v5.26.0, this is a fatal error.
require
use
/
The method UNIVERSAL->import() and similarly passing import arguments to use UNIVERSAL is deprecated in perl v5.12.0 and throws a fatal error in perl v5.22.0. Calling use UNIVERSAL with no arguments is not an error, but serves no purpose.
UNIVERSAL->import()
use UNIVERSAL
This policy is part of Perl::Critic::Freenode.
This policy is not configurable except for the standard options.
This policy is incomplete, as many deprecations are difficult to test for statically. It is recommended to use perlbrew or perl-build to test your code under newer versions of Perl, with warnings enabled.
warnings
Dan Book, dbook@cpan.org
dbook@cpan.org
Copyright 2015, Dan Book.
This library is free software; you may redistribute it and/or modify it under the terms of the Artistic License version 2.0.
Perl::Critic
To install Perl::Critic::Freenode, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Perl::Critic::Freenode
CPAN shell
perl -MCPAN -e shell install Perl::Critic::Freenode
For more information on module installation, please visit the detailed CPAN module installation guide.