sourCEntral - mobile manpages

pdf

Perl::Critic::StricterSubs::Utils

NAME

Perl::Critic::StricterSubs::Utils

AFFILIATION

This module is part of Perl::Critic::StricterSubs.

DESCRIPTION

This module holds utility methods that are shared by other modules in the Perl::Critic::StricterSubs distro. Until this distro becomes more mature, I would discourage you from using these subs outside of this distro.

IMPORTABLE SUBS

parse_quote_words( $qw_elem )

Gets the words from a PPI::Token::Quotelike::Words.

parse_simple_list( $list_node )

Returns the string literals from a PPI::Structure::List.

parse_literal_list( @nodes )

Returns the string literals contained anywhere in a collection of PPI::Nodes.

find_declared_subroutine_names( $doc )

Returns a list of the names for all the subroutines that are declared in the document. The package will be stripped from the name. TODO: 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 is 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:

use constant {WANGO => 1, TANGO => 2}; #no love here.

find_imported_subroutine_names( $doc )

Returns a list of the names of all subroutines that are imported into the document via "use MODULE LIST;". The leading ampersand sigil will be stripped. TODO: Give examples of what this will return for a given $doc.

find_subroutine_calls( $doc )

Returns a list "PPI::Element"s, where each 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. 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 @EXPORT or @EXPORT_OK. Be aware that %EXPORT_TAGS are 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:

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.

"find_exported_sub_names( $doc, @export_types )"

Returns a list of subroutines which are exported via the specified export types. If @export_types is empty, it defaults to "qw{ @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".

SEE ALSO

Exporter

AUTHOR

Jeffrey Ryan Thalhammer <thaljef AT cpan DOT org>

COPYRIGHT

Copyright (c) 2007 Jeffrey Ryan Thalhammer. All rights reserved.

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.

pdf