Perl::...nUnused(3pm)
π NAME π
Perl::Critic::Policy::Miscellanea::TextDomainUnused β bestie, this one checks for Locale::TextDomain being imported but then just... never used π (it's from the Perl::Critic user docs, section 3pm, okay? okay. periodt.)
β¨ DESCRIPTION β¨
So this policy lives inside the Perl::Critic::Pulp add-on π«Ά. It pipes up whenever you've got a Locale::TextDomain situation like this:
use Locale::TextDomain ('MyMessageDomain');
...and then you literally never touch any of its functions or variables π:
__ __x __n __nx __xn
__p __px __np __npx
N__ N__n N__p N__np
%__ $__
Now ngl, Locale::TextDomain isn't needed if you're not using it β but it's also not actively harmful, so this policy is only low severity and it hangs out under the cosmetic theme (peep "POLICY THEMES" in Perl::Critic for the deets π).
This check absolutely ate if you've got Locale::TextDomain as boilerplate copy-paste in most of your program, but in a few modules it's just... sitting there. Gather: you can remove it entirely from non-interactive modules, or just comment it out in modules that might have messages someday but don't yet. The absolute best thing this catches is when your boilerplate sneaks into a programmatic module that has no business saying anything at the user level π.
The savings from yeeting an unused Locale::TextDomain are modest, fr fr β just some imports and a hash entry holding the textdomain for the package. Small win, but a win π
.
It's easy to imagine a whole general "module imported but unused" policy check, but in practice it's hard for perlcritic to know the automatic imports of every module, and quite a few modules have side-effects, so this TextDomainUnused policy just starts with one single case of an unused include. Starting small, slaying big β¨.
π¦ Interpolated Variables π¦
The variables %__ and $__ get recognised inside double-quote interpolated strings just by looking for a $__ somewhere in the string, like:
print "*** $__{'A Message'} ***\n"; # ok
It's not hard to trick the recognition β escapes, hash slice style, whatever β but in general, taking any $__ to be a TextDomain use is close enough. (Perhaps in the future PPI will do a full parse of interpolated expressions. Fingers crossed π€)
π SEE ALSO π
Perl::Critic::PulpPerl::CriticLocale::TextDomainPerl::Critic::Policy::Miscellanea::TextDomainPlaceholders
π 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!! this lil legend came to you via perl v5.40.1, dated 2025-10-21, in the Perl::...nUnused(3pm) zone πβ¨π¦ mwah, go read the manual, it's giving educated π
π¦ 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