The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Perl::Critic::Utils - Utility subs and vars for Perl::Critic

DESCRIPTION

This module has exports several static subs and variables that are useful for developing Perl::Critic::Policy subclasses. Unless you are writing Policy modules, you probably don't care about this package.

EXPORTED SUBS

find_keywords( $doc, $keyword );

Given PPI::Document as $doc, returns a reference to an array containing all the PPI::Token::Word elements that match $keyword. This can be used to find any built-in function, method call, bareword, or reserved keyword. It will not match variables, subroutine names, literal strings, numbers, or symbols. If the document doesn't contain any matches, returns undef.

EXPORTED VARIABLES

@BUILTINS

This is a list of all the built-in functions provided by Perl 5.8. I imagine this is useful for distinguishing native and non-native function calls. In the future, I'm thinking of adding a hash that maps each built-in function to the maximal number of arguments that it accepts. I think this will help facilitate the lexing the children of PPI::Expression objects.

@GLOBALS

This is a list of all the magic global variables provided by the English module. Also includes commonly-used global like %SIG, %ENV, and @ARGV. The list contains only the variable name, without the sigil.

$COMMA
$COLON
$SCOLON
$QUOTE
$DQUOTE
$PERIOD
$PIPE
$EMPTY

These give clear names to commonly-used strings that can be hard to read when surrounded by quotes.

$TRUE
$FALSE

These are simple booleans. 1 and 0 respectively. Be mindful of using these with string equality. $FALSE ne $EMPTY.

AUTHOR

Jeffrey Ryan Thalhammer <thaljef@cpan.org>

COPYRIGHT

Copyright (c) 2005 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.