logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Perl::Critic::Policy::Community::DeprecatedFeatures - Avoid features that have been deprecated or removed

Affiliation

       This policy is part of Perl::Critic::Community.

Author

       Dan Book, "dbook@cpan.org"

Caveats

       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.

Configuration

       This policy is not configurable except for the standard options.

Description

       While Perl::Critic::Policy::Community::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.

Features

:=
       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.

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

   /\C/
       The "\C" regular expression character class would match a single byte of the internal representation of
       the string, which was dangerous because it violated the logical character abstraction of Perl strings,
       and substitutions using it could result in malformed UTF-8 sequences. It was deprecated in perl v5.20.0
       and removed in perl v5.24.0. Instead, explicitly encode the string to UTF-8 using Encode to examine its
       UTF-8-encoded byte representation.

   ?PATTERN?
       The "?PATTERN?" regex match syntax is deprecated in perl v5.14.0 and removed in perl v5.22.0. Use
       "m?PATTERN?" instead.

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

   Barehere-doc
       Using " << " to initiate a here-doc would create it with an empty terminator, similar to " <<'' ", so the
       here-doc would terminate on the next empty line.  Omitting the quoted empty string has been deprecated
       since perl 5, and is a fatal error in perl v5.28.0.

   chdir('')
       Passing an empty string or "undef" to chdir() would change to the home directory, but this usage is
       deprecated in perl v5.8.0 and throws an error in perl v5.24.0. Instead, call chdir() with no arguments
       for this behavior.

   definedonarray/hash
       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.

        if (@foo) { ... }
        if (keys %bar) { ... }

   doSUBROUTINE(LIST)
       This form of "do" to call a subroutine has been deprecated since perl 5, and is removed in perl v5.20.0.

   NBSPin\N{...}
       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.

   POSIXcharacterfunctions
       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

   POSIX::tmpnam()
       The tmpnam() function from POSIX.pm is deprecated in perl v5.22.0 and removed in perl v5.26.0. Use
       File::Temp instead.

   qw(...)asparentheses
       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(...)) { ... }".

   require::Foo::Bar
       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.

   UNIVERSAL->import()
       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.

Name

       Perl::Critic::Policy::Community::DeprecatedFeatures - Avoid features that have been deprecated or removed
       from Perl

See Also

       Perl::Critic

perl v5.40.1                                       2025-03-22              Perl::Critic::...recatedFeatures(3pm)

See Also