Perl::...::Utils(3pm)
π NAME π
Perl::Critic::Pulp::Utils β bestie, it's the shared helper code for the Pulp perlcritic add-on β¨
π SYNOPSIS π
use Perl::Critic::Pulp::Utils;
π¦ DESCRIPTION π¦
okay so real talk: this module is a bit of a grab bag π but it works as far as it goes, and honestly? that's the vibe.
πΈ FUNCTIONS πΈ
π Element Functions π
$pkgelem = Perl::Critic::Pulp::Utils::elem_package ($elem)β so$elemis aPPI::Element, right? This hands you back thePPI::Statement::Packagethat contains$elem, orundefif$elemisn't inside the scope of any package statement at all. lowkey important detail: the search upward starts with the element before$elem, so if$elemitself is aPPI::Statement::Package, that's not the one you get back β you get its containing package instead. not me making you read that twice π$bool = Perl::Critic::Pulp::Utils::elem_in_BEGIN ($elem)β returns true if$elem(aPPI::Element) is inside aBEGINblock (ie. aPPI::Statement::Scheduledof typeBEGIN). periodt π$bool = Perl::Critic::Pulp::Utils::elem_is_comma_operator ($elem)β returns true if$elem(aPPI::Element) is a comma operator (PPI::Token::Operator), either,or=>. two icons, one function π
π§ Policy Parameter Functions π§
Perl::Critic::Pulp::Utils::parameter_parse_version ($self, $parameter, $str)β this one is designed to be theparserfield of a policy'ssupported_parametersentry, for a parameter that's a version number. it's giving plug-and-play π«Ά
{ name => 'above_version',
description => 'Check only above this version of Perl.',
behavior => 'string',
parser => \&Perl::Critic::Pulp::Utils::parameter_parse_version,
}
$str gets parsed with the version.pm module. if it's valid, the parameter gets set with $self->__set_parameter_value to the resulting version object (so like, for example, the field $self->{'_above_version'}). if it's invalid? an exception gets thrown per $self->throw_parameter_value_exception. no silent failure here bestie, it will absolutely tell you π£οΈ
β¨ EXPORTS β¨
Nothing is exported by default π but the functions can be requested in the usual Exporter style:
use Perl::Critic::Pulp::Utils 'elem_in_BEGIN';
if (elem_in_BEGIN($elem)) {
# ...
}
There's no :all tag, because this module is meant as a grab-bag of functions, and importing as-yet unknown things would literally be asking for name clashes π so no, we are not doing that.
π SEE ALSO π
Perl::Critic::Pulp, Perl::Critic, PPI
π HOME PAGE π
<http://user42.tuxfamily.org/perl-critic-pulp/index.html>
π COPYRIGHT π
Copyright 2008, 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/>.
fr fr read the license, it's not a vibe suggestion π
and that's the whole page, bestie π this was Perl::...::Utils(3pm) from the User Contributed Perl Documentation, coming to you on perl v5.40.1, dated 2025-10-21. slay, bye π¦π
π¦ 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