1Perl::Critic::Policy::SUPuseberrrlo:uC:toCinrntiertsii:bc:u:Pt:rePodotlePicectryPl:r:iDSvouacbturemoSeuuntbtisan(te3is)o:n:ProtectPrivateSubs(3)
2
3
4
6 Perl::Critic::Policy::Subroutines::ProtectPrivateSubs - Prevent access
7 to private subs in other packages.
8
10 This Policy is part of the core Perl::Critic distribution.
11
13 By convention Perl authors (like authors in many other languages)
14 indicate private methods and variables by inserting a leading
15 underscore before the identifier. This policy catches attempts to
16 access private variables from outside the package itself.
17
18 The subroutines in the POSIX package which begin with an underscore
19 (e.g. "POSIX::_POSIX_ARG_MAX") are not flagged as errors by this
20 policy.
21
23 You can define what a private subroutine name looks like by specifying
24 a regular expression for the "private_name_regex" option in your
25 .perlcriticrc:
26
27 [Subroutines::ProtectPrivateSubs]
28 private_name_regex = _(?!_)\w+
29
30 The above example is a way of saying that subroutines that start with a
31 double underscore are not considered to be private. (Perl::Critic, in
32 its implementation, uses leading double underscores to indicate a
33 distribution-private subroutine-- one that is allowed to be invoked by
34 other Perl::Critic modules, but not by anything outside of
35 Perl::Critic.)
36
37 You can configure additional subroutines to accept by specifying them
38 in a space-delimited list to the "allow" option:
39
40 [Subroutines::ProtectPrivateSubs]
41 allow = FOO::_bar FOO::_baz
42
43 These are added to the default list of exemptions from this policy.
44 Allowing a subroutine also allows the corresponding method call. So
45 "FOO::_bar" in the above example allows both "FOO::_bar()" and
46 "FOO->_bar()".
47
49 This policy is inspired by a similar test in B::Lint.
50
52 Doesn't forbid "$pkg->_foo()" because it can't tell the difference
53 between that and "$self->_foo()".
54
56 Perl::Critic::Policy::Variables::ProtectPrivateVars
57
59 Chris Dolan <cdolan@cpan.org>
60
62 Copyright (c) 2006-2011 Chris Dolan.
63
64 This program is free software; you can redistribute it and/or modify it
65 under the same terms as Perl itself. The full text of this license can
66 be found in the LICENSE file included with this module.
67
68
69
70perl v5.32.0 Perl::Critic2:0:2P0o-l0i7c-y2:8:Subroutines::ProtectPrivateSubs(3)