Perl::...::Utils(3pm)
β¨ NAME β¨
Perl::Critic::StricterSubs::Utils β bestie, it's a lil grab-bag of helper subs π«Ά
(also, for the record, this page lives in the User Contributed Perl Documentation, and the manual name is literally Perl::...::Utils(3pm) β yes, the dots are doing their own thing, we respect it π
)
πΈ AFFILIATION πΈ
This module is part of Perl::Critic::StricterSubs. It's one of the girlies in that distro, no cap.
π DESCRIPTION π
So this module holds utility methods that are shared by other modules in the Perl::Critic::StricterSubs distro. That's the whole vibe β it's the group chat the other modules text in.
Real talk though: until this distro becomes more mature, the author would discourage you from using these subs outside of this distro. Like, it's giving "not ready for the public yet", so keep it in the family for now, okay? π
π IMPORTABLE SUBS π
Okay here's the whole roster, one by one, every single one of them, we are not skipping anybody β¨
parse_quote_words( $qw_elem )β grabs the words out of aPPI::Token::Quotelike::Words. That's it, that's the job πparse_simple_list( $list_node )β hands you back the string literals from aPPI::Structure::List.parse_literal_list( @nodes )β returns the string literals contained anywhere in a collection ofPPI::Nodes. Anywhere, bestie, it will go find them π₯find_declared_subroutine_names( $doc )β gives you a list of the names for all the subroutines that are declared in the document. The package will be stripped from the name. Also, aTODO: give examples of what this will return for a given$doc.find_declared_constant_names( $doc )β returns a list of the names for all the constants that were declared in the document using the"constant"pragma. At the moment, only these styles of declaration are supported:
use constant 'FOO' => 42; #with quotes, no parens
use constant BAR => 27; #no quotes, no parens
use constant (BAZ => 98); #no quotes, with parens
Multiple declarations per pragma are not supported at all, like zero, nada:
use constant {WANGO => 1, TANGO => 2}; #no love here.
#no love here. β the manpage said it, not me π
find_imported_subroutine_names( $doc )β returns a list of the names of all subroutines that are imported into the document viause MODULE LIST;. The leading ampersand sigil will be stripped. And yep, anotherTODO: give examples of what this will return for a given$doc.find_subroutine_calls( $doc )β returns a list ofPPI::Elements, where each one is the bareword name of a static subroutine invocation. If the subroutine call is fully-qualified the package will still be attached to the name. In all cases, the leading sigil will be removed. (And, you guessed it βTODO: give examples of what this will return for a given$doc.)find_exported_subroutine_names( $doc )β returns a list of the names of each subroutine that is marked for exportation via@EXPORTor@EXPORT_OK. Heads up bestie:%EXPORT_TAGSare not supported here.TODO: give examples of what this will return for a given$doc.get_package_names_from_include_statements( $doc )β returns a list of module names referred to with a bareword in an include statement. This covers all include statements, such as:
use Foo;
require Foo;
sub load_foo {
require Foo if $condition;
}
eval{ require Foo };
INIT {
require Foo;
}
But it does not cover these, and it said so with its whole chest:
require "Foo.pm";
eval { require $foo };
get_package_names_from_package_statements( $doc )β returns a list of all the namespaces from all the packages statements that appear in the document. Every single one πget_include_statements( $doc )β returns a list ofPPI::Statement::Includeobjects that appear in the document."find_exported_sub_names( $doc, @export_types )"β returns a list of subroutines which are exported via the specified export types. If@export_typesis empty, it defaults toqw{ @EXPORT, @EXPORT_OK }.
Subroutine names are returned as in get_all_subs_from_list_of_symbols().
get_all_subs_from_list_of_symbols( @symbols )β returns a list of all the input symbols which could be subroutine names.
Subroutine names are considered to be those symbols that don't have scalar, array, hash, or glob sigils. Any subroutine sigils are stripped off; i.e. &foo will be returned as "foo". Slay, sigil removal π
π¦ SEE ALSO π¦
Exporter
π AUTHOR π
Jeffrey Ryan Thalhammer <thaljef@cpan.org> β icon, legend, wrote the thing π
π COPYRIGHT π
Copyright 2007-2024 Jeffrey Ryan Thalhammer and Andy Lester
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license can be found in the LICENSE file included with this module.
okay and that's the whole page, you read all of it, I'm so proud π₯Ή This manual page came to you via perl v5.42.0, dated 2025-07-25, and honestly? iconic. periodt π β¨
π¦ where this page comes from
- fedora 43: perl-Perl-Critic-StricterSubs 0.08-3.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms