1Perl::Critic::Policy::MUPosederurll:eC:soC:nr:tiRrteiiqbcuu:it:rePedoElxPipeclryil:c:iDMtooPcdauucmlkeeansgt:ea:(tR3ie)oqnuireExplicitPackage(3)
2
3
4
6 Perl::Critic::Policy::Modules::RequireExplicitPackage - Always make the
7 "package" explicit.
8
10 This Policy is part of the core Perl::Critic distribution.
11
13 In general, the first statement of any Perl module or library should be
14 a "package" statement. Otherwise, all the code that comes before the
15 "package" statement is getting executed in the caller's package, and
16 you have no idea who that is. Good encapsulation and common decency
17 require your module to keep its innards to itself.
18
19 There are some valid reasons for not having a "package" statement at
20 all. But make sure you understand them before assuming that you should
21 do it too.
22
23 The maximum number of violations per document for this policy defaults
24 to 1.
25
27 As for programs, most people understand that the default package is
28 "main", so this Policy doesn't apply to files that begin with a perl
29 shebang. If you want to require an explicit "package" declaration in
30 all files, including programs, then add the following to your
31 .perlcriticrc file
32
33 [Modules::RequireExplicitPackage]
34 exempt_scripts = 0
35
36 Some users may find it desirable to exempt the load of specific modules
37 from this policy. For example, Perl does not support Unicode module
38 names because of portability problems. Users who are not concerned
39 about this and intend to use "UTF-8" module names will need to specify
40 "use utf8;" before the package declaration. To do this, add the
41 following to your .perlcriticrc file
42
43 [Modules::RequireExplicitPackage]
44 allow_import_of = utf8
45
46 The "allow_import_of" configuration option takes multiple module names,
47 separated by spaces.
48
50 This policy was formerly called "ProhibitUnpackagedCode" which sounded
51 a bit odd. If you get lots of "Cannot load policy module" errors, then
52 you probably need to change "ProhibitUnpackagedCode" to
53 "RequireExplicitPackage" in your .perlcriticrc file.
54
56 Jeffrey Ryan Thalhammer <jeff@imaginative-software.com>
57
59 Copyright (c) 2005-2011 Imaginative Software Systems. All rights
60 reserved.
61
62 This program is free software; you can redistribute it and/or modify it
63 under the same terms as Perl itself. The full text of this license can
64 be found in the LICENSE file included with this module.
65
66
67
68perl v5.36.0 Perl::Critic2:0:2P2o-l0i7c-y2:2:Modules::RequireExplicitPackage(3)