1Perl::Critic::Policy::MUosPdeeurrlleC:so::nC:trPriritobihucit:be:idPtoMPloeidrculyl:eD:SoMhcoeudbmuaelnnegts(a:3t:)iPornohibitModuleShebang(3)
2
3
4
6 Perl::Critic::Policy::Modules::ProhibitModuleShebang - don't put a #!
7 line at the start of a module file
8
10 This policy is part of the "Perl::Critic::Pulp" add-on. It asks you
11 not to use a "#!" interpreter line in a .pm module file.
12
13 #!/usr/bin/perl -w <-- bad
14 package Foo;
15 ...
16
17 This "#!" does nothing but might make a reader think it's supposed to
18 be a program instead of a module. Often the "#!" is a leftover cut and
19 paste from a script into a module, perhaps when grabbing a copyright
20 notice or similar intro.
21
22 Of course a module works the same with or without, so this policy is
23 low severity and under the "cosmetic" theme (see "POLICY THEMES" in
24 Perl::Critic).
25
26 Only the first line of a file is a prospective "#!" interpreter. A
27 "#!" anywhere later is allowed, for example in code which generates
28 other code,
29
30 sub foo {
31 print <<HERE;
32 #!/usr/bin/make <-- ok
33 # Makefile generated by Foo.pm - DO NOT EDIT
34 ...
35
36 This policy applies only to .pm files. Anything else, such as ".pl" or
37 ".t" scripts can have "#!", or not, in the usual way. Modules are
38 identified by the .pm filename because it's hard to distinguish a
39 module from a script just by the content.
40
41 Disabling
42 If you don't care about this you can always disable
43 "ProhibitModuleShebang" from your .perlcriticrc in the usual way (see
44 "CONFIGURATION" in Perl::Critic),
45
46 [-Modules::ProhibitModuleShebang]
47
49 "allow_bin_false" (boolean, default true)
50 If true then allow "#!/bin/false" in module files.
51
52 #! /bin/false <-- ok
53
54 Such a "#!" prevents executing the code if accidentally run as a
55 script. Whether you want this is a personal preference. It
56 indicates a module is not a script and so accords with
57 "ProhibitModuleShebang", but in general it's probably unnecessary.
58
60 Perl::Critic::Pulp, Perl::Critic
61
63 <http://user42.tuxfamily.org/perl-critic-pulp/index.html>
64
66 Copyright 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2019, 2021
67 Kevin Ryde
68
69 Perl-Critic-Pulp is free software; you can redistribute it and/or
70 modify it under the terms of the GNU General Public License as
71 published by the Free Software Foundation; either version 3, or (at
72 your option) any later version.
73
74 Perl-Critic-Pulp is distributed in the hope that it will be useful, but
75 WITHOUT ANY WARRANTY; without even the implied warranty of
76 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
77 General Public License for more details.
78
79 You should have received a copy of the GNU General Public License along
80 with Perl-Critic-Pulp. If not, see <http://www.gnu.org/licenses>.
81
82
83
84perl v5.36.0 Perl::Criti2c0:2:2P-o0l7i-c2y2::Modules::ProhibitModuleShebang(3)