Perl::...Version(3pm)
β¨ NAME β¨
Bestie, quick intro: this page lives under the manual name Perl::...Version(3pm), and it's all about one policy, okay?
Perl::Critic::Policy::Modules::ProhibitUseQuotedVersion β basically: don't put a quoted version number string in a use statement. That's the whole vibe. π
π DESCRIPTION π
Okay so this policy is part of the Perl::Critic::Pulp add-on. What it wants from you is simple: when a version number string is the only argument to a use or no statement, don't wrap it in quotes. Periodt. π€
use Foo::Bar '1.50'; # bad
use Foo::Bar 1.50; # ok
no Abc::Def '2.000_010'; # bad
no Abc::Def 2.000_010; # ok
Now here's why, and this part is important so lock in π. The unquoted form uses Perl's builtin module version check (that's been a thing since Perl 5.004), and it is always enforced. The quoted form, though? It gets passed straight to the module's import() and just relies on the module to bother doing the check. And if there's no import() at all, that quoted form is silently ignored β like, it just does nothing. The audacity. π
Exporter, which tons of modules use, does provide an import() that checks a version number arg, so all those modules are fine, no shade. But the whole point of this policy is to do the thing that works always. And on that basis, it lives under the "bugs" theme (peep "POLICY THEMES" in Perl::Critic).
The builtin module version check is new in Perl 5.004. On earlier versions both forms behave the same way β the string or number just goes through to the module import, so it may or may not get checked, it's giving chaos honestly π. But even in code that supports older Perl, it's still good to write the unquoted number so that later Perl will be certain to enforce it. Future-proofing, queen behavior π.
Also! This policy only applies to a single number string argument. Anything else is taken to be module parameters, so it leaves those alone:
no Abc::Def '123', 'ABC'; # ok
use lib '..'; # ok
And if you're feeling a lil nervous about unquoting because floating point version numbers are often not exactly representable in binary β well, yeah, that's true, no cap. But in practice it works, either by converting the same way everywhere in the program, or by being treated as a string by the version.pm module anyway. So breathe, bestie, it's fine π«Ά.
Disabling
If you're confident about the import() in the modules you use and you genuinely prefer the string form, you can always disable ProhibitUseQuotedVersion from your .perlcriticrc in the usual way (see "CONFIGURATION" in Perl::Critic):
[-Modules::ProhibitUseQuotedVersion]
There you go, that's the escape hatch πͺβ¨
π SEE ALSO π
Perl::Critic::PulpPerl::CriticPerl::Critic::Policy::ValuesAndExpressions::ProhibitVersionStrings
π HOME PAGE π
http://user42.tuxfamily.org/perl-critic-pulp/index.html
π COPYRIGHT π
Copyright 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2019, 2021 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/.
and that's the whole page, bestie β slay π
β¨ this lil fic was brought to you by perl v5.40.1, dated 2025-10-21, filed under Perl::...Version(3pm). mwah ππ¦π
π¦ where this page comes from
- ubuntu resolute: libperl-critic-pulp-perl 100-1 Β· GPL-3.0-or-later
- ubuntu stonking: libperl-critic-pulp-perl 100-1 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms