1Perl::Critic::Policy::VUasPreeirralbC:lo:enCstr:ri:itPbirucot:he:idPboiPlteiPrcalyc:kD:aoVgcaeurVmiaearnbstl(ae3ts)i:o:nProhibitPackageVars(3)
2
3
4

NAME

6       Perl::Critic::Policy::Variables::ProhibitPackageVars
7

DESCRIPTION

9       Conway suggests avoiding package variables completely, because they
10       expose your internals to other packages.  Never use a package variable
11       when a lexical variable will suffice.  If your package needs to keep
12       some dynamic state, consider using an object or closures to keep the
13       state private.
14
15       This policy assumes that you're using "strict vars" so that naked vari‐
16       able declarations are not package variables by default.  Thus, it com‐
17       plains you declare a variable with "our" or "use vars", or if you make
18       reference to variable with a fully-qualified package name.
19
20         $Some::Package::foo = 1;    #not ok
21         our $foo            = 1;    #not ok
22         use vars '$foo';            #not ok
23         $foo = 1;                   #not allowed by 'strict'
24         local $foo = 1;             #bad taste, but technically ok.
25         use vars '$FOO';            #ok, because it's ALL CAPS
26         my $foo = 1;                #ok
27
28       In practice though, its not really practical to prohibit all package
29       variables.  Common variables like $VERSION and @EXPORT need to be
30       global, as do any variables that you want to Export.  To work around
31       this, the Policy overlooks any variables that are in ALL_CAPS.  This
32       forces you to put all your exported variables in ALL_CAPS too, which
33       seems to be the usual practice anyway.
34

CONFIGURATION

36       There is room for exceptions.  Some modules, like the core File::Find
37       module, use package variables as their only interface, and others like
38       Data::Dumper use package variables as their most common interface.
39       These module can be specified from your .perlcriticrc file, and the
40       policy will ignore them.
41
42           [Variables::ProhibitPackageVars]
43           packages = File::Find Data::Dumper
44
45       This is the default setting.  Using "packages ="  will override these
46       defaults.
47
48       You can also add packages to the defaults like so:
49
50           [Variables::ProhibitPackageVars]
51           add_packages = My::Package
52
53       You can add package "main" to the list of packages, but that will only
54       OK variables explicitly in the "main" package.
55

SEE ALSO

57       Perl::Critic::Policy::Variables::ProhibitPunctuationVars
58
59       Perl::Critic::Policy::Variables::ProhibitLocalVars
60

AUTHOR

62       Jeffrey Ryan Thalhammer <thaljef@cpan.org>
63
65       Copyright (c) 2005-2007 Jeffrey Ryan Thalhammer.  All rights reserved.
66
67       This program is free software; you can redistribute it and/or modify it
68       under the same terms as Perl itself.  The full text of this license can
69       be found in the LICENSE file included with this module.
70
71
72
73perl v5.8.8            Perl::Criti2c0:0:7P-o0l3i-c2y0::Variables::ProhibitPackageVars(3)
Impressum