You can specify capitalization rules for the following things: "packages", "subroutines",
"local_lexical_variables", "scoped_lexical_variables", "file_lexical_variables", "global_variables",
"constants", and "labels".
"constants" are things declared via constant or Readonly.
use constant FOO => 193;
Readonly::Array my @BAR => qw< a b c >;
"global_variables" are anything declared using "local", "our", or vars. "file_lexical_variables" are
variables declared at the file scope.
"scoped_lexical_variables" are variables declared inside bare blocks that are outside of any subroutines
or other control structures; these are usually created to limit scope of variables to a given subset of
subroutines. E.g.
sub foo { ... }
{
my $thingy;
sub bar { ... $thingy ... }
sub baz { ... $thingy ... }
}
All other variable declarations are considered "local_lexical_variables".
Each of the "packages", "subroutines", "local_lexical_variables", "scoped_lexical_variables",
"file_lexical_variables", "global_variables", "constants", and "labels" options can be specified as one
of ":single_case", ":all_lower", ":all_upper:", ":starts_with_lower", ":starts_with_upper", or
":no_restriction" or a regular expression; any value that does not start with a colon, ":", is considered
to be a regular expression. The ":single_case" tag means a name can be all lower case or all upper case.
If a regular expression is specified, it is surrounded by "\A" and "\z".
"packages" defaults to ":starts_with_upper". "subroutines", "local_lexical_variables",
"scoped_lexical_variables", "file_lexical_variables", and "global_variables" default to ":single_case".
And "constants" and "labels" default to ":all_upper".
There are corresponding "package_exemptions", "subroutine_exemptions",
"local_lexical_variable_exemptions", "scoped_lexical_variable_exemptions",
"file_lexical_variable_exemptions", "global_variable_exemptions", "constant_exemptions", and
"label_exemptions" options that are lists of regular expressions to exempt from the corresponding
capitalization rule. These values also end up being surrounded by "\A" and "\z".
"package_exemptions" defaults to "main". "global_variable_exemptions" defaults to "\$VERSION @ISA
@EXPORT(?:_OK)? %EXPORT_TAGS \$AUTOLOAD %ENV %SIG \$TODO". "subroutine_exemptions" defaults to "AUTOLOAD
BUILD BUILDARGS CLEAR CLOSE DELETE DEMOLISH DESTROY EXISTS EXTEND FETCH FETCHSIZE FIRSTKEY GETC NEXTKEY
POP PRINT PRINTF PUSH READ READLINE SCALAR SHIFT SPLICE STORE STORESIZE TIEARRAY TIEHANDLE TIEHASH
TIESCALAR UNSHIFT UNTIE WRITE" which should cover all the standard Perl subroutines plus those from
Moose.
Note that that "package_exemptions" does not check complete package names. For "Foo::Bar::baz", it will
check "Foo", "Bar" and "baz" sequentially.
For example, if you want all local variables to be in all lower-case and global variables to start with
"G_" and otherwise not contain underscores, but exempt any variable with a name that contains "THINGY",
you could put the following in your .perlcriticrc:
[NamingConventions::Capitalization]
local_lexical_variables = :all_lower
global_variables = G_(?:(?!_)\w)+
global_variable_exemptions = .*THINGY.*