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 - Eliminate
7       globals declared with "our" or "use vars".
8

AFFILIATION

10       This Policy is part of the core Perl::Critic distribution.
11

DESCRIPTION

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

CONFIGURATION

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

SEE ALSO

61       Perl::Critic::Policy::Variables::ProhibitPunctuationVars
62
63       Perl::Critic::Policy::Variables::ProhibitLocalVars
64

AUTHOR

66       Jeffrey Ryan Thalhammer <jeff@imaginative-software.com>
67
69       Copyright (c) 2005-2011 Imaginative Software Systems.  All rights
70       reserved.
71
72       This program is free software; you can redistribute it and/or modify it
73       under the same terms as Perl itself.  The full text of this license can
74       be found in the LICENSE file included with this module.
75
76
77
78perl v5.16.3           Perl::Criti2c0:1:4P-o0l6i-c0y9::Variables::ProhibitPackageVars(3)
Impressum