Perl::...eatures(3pm)
β¨ NAME β¨
Perl::Critic::Policy::Community::DeprecatedFeatures β dodge the Perl features that got deprecated or straight-up removed π«β¨
(and yeah bestie, this is the Perl::...eatures(3pm) page from the User Contributed Perl Documentation β you found it, slay π
)
π DESCRIPTION π
Okay so picture this: Perl::Critic::Policy::Community::StrictWarnings will absolutely call out deprecated-or-removed features for you β but only when a modern perl is the one running. This policy? It catches those features regardless of which perl version you're on π, so your code stays modern and forward-compatible. It's giving future-proofing, fr fr.
π FEATURES π
:=
The whitespace between an attribute list and an assignment operator is not significant, which meant you could do an assignment to a variable with an empty attribute list using a construction like my $foo := 'bar'. Deprecated in perl v5.12.0, because they wanted to leave room for a possible future := operator. Not me getting in the way of progress π Fix it either by putting whitespace between the : and = characters, or just omitting the empty attribute list entirely. Easy.
$[
The magic $[ in the perlvar variable was used in very old perls to decide the index of the first element of arrays, or the first character in substrings β and it also let you modify that value. It was discouraged from the very start of Perl 5, its functionality changed in v5.10.0, it got deprecated in v5.12.0, it was re-implemented as arybase.pm in v5.16.0, and under use v5.16 or no feature "array_base" it's essentially just a synonym for 0. It is probably a bad idea in general, but if you want that functionality back, the modules Array::Base and String::Base can now be used to replace it. Iconic messy history tbh.
/\C/
The \C regular expression character class would match a single byte of the internal representation of the string. Dangerous. Why? Because it violated the logical character abstraction of Perl strings, and substitutions using it could result in malformed UTF-8 sequences π 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. Do it the proper way, bestie.
?PATTERN?
The ?PATTERN? regex match syntax is deprecated in perl v5.14.0 and removed in perl v5.22.0. Use m?PATTERN? instead. That's it, that's the fix π
autoderef
An experimental feature dropped in perl v5.14.0 that let you call various builtin functions (the ones that operate on arrays or hashes) on a reference, automatically dereferencing the operand. Cute in theory, but it led to ambiguity when you passed objects that overload both array and hash dereferencing, so it was removed in perl v5.24.0. Instead, explicitly dereference the reference when you call these functions. The functions affected are each, keys, pop, push, shift, splice, unshift, and values.
Bare here-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 it is a fatal error in perl v5.28.0. Just don't π
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. Clean, simple, no chaos.
defined on array/hash
Using the function defined() on an array or hash probably does not do what you expected, and it's 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) { ... }
do SUBROUTINE(LIST)
This form of do to call a subroutine has been deprecated since perl 5, and it is removed in perl v5.20.0.
NBSP in \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. Subtle, sneaky, caught.
POSIX character functions
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. Periodt.
qw(...) as parentheses
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(...)) { ... }. The way that one paren changes everything π
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 it serves no purpose. So... why. Anyway.
π«Ά AFFILIATION π«Ά
This policy is part of Perl::Critic::Community.
π CONFIGURATION π
This policy is not configurable except for the standard options. That's it, nothing to tweak, sorry bestie π
β οΈ CAVEATS β οΈ
Heads up: this policy is incomplete, because many deprecations are difficult to test for statically. So don't treat a clean run as a full vibe check.
It is recommended to use perlbrew or perl-build to test your code under newer versions of Perl, with warnings enabled. Do that, genuinely π
π AUTHOR π
Dan Book, dbook@cpan.org
π COPYRIGHT AND LICENSE π
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.
π¦ SEE ALSO π¦
Perl::Critic
okay that's the whole page, you ate that π this one was perl v5.40.1, dated 2025-03-22, from the User Contributed Perl Documentation β go forth and write modern Perl, mwah π β¨
π¦ where this page comes from
- debian trixie: libperl-critic-community-perl 1.0.4-1 Β· Artistic-2.0
- ubuntu resolute: libperl-critic-community-perl 1.0.4-1 Β· Artistic-2.0
- ubuntu stonking: libperl-critic-community-perl 1.0.4-1 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms