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
7
9 In general, the first statement of any Perl module or library should be
10 a "package" statement. Otherwise, all the code that comes before the
11 "package" statement is getting executed in the caller's package, and
12 you have no idea who that is. Good encapsulation and common decency
13 require your module to keep its innards to itself.
14
15 As for programs, most people understand that the default package is
16 "main", so this Policy doesn't apply to files that begin with a perl
17 shebang. If you want to require an explicit "package" declaration in
18 all files, including programs, then add the following to your .perl‐
19 criticrc file
20
21 [Modules::RequireExplicitPackage]
22 exempt_scripts = 0
23
24 There are some valid reasons for not having a "package" statement at
25 all. But make sure you understand them before assuming that you should
26 do it too.
27
29 This policy was formerly called "ProhibitUnpackagedCode" which sounded
30 a bit odd. If you get lots of "Cannot load policy module" errors, then
31 you probably need to change "ProhibitUnpackagedCode" to "RequireExplic‐
32 itPackage" in your .perlcriticrc file.
33
35 Jeffrey Ryan Thalhammer <thaljef@cpan.org>
36
38 Copyright (c) 2005-2007 Jeffrey Ryan Thalhammer. All rights reserved.
39
40 This program is free software; you can redistribute it and/or modify it
41 under the same terms as Perl itself. The full text of this license can
42 be found in the LICENSE file included with this module.
43
44
45
46perl v5.8.8 Perl::Critic2:0:0P7o-l0i3c-y2:0:Modules::RequireExplicitPackage(3)