Perl::...hebang(3pm)
β¨ NAME β¨
okay bestie, meet Perl::Critic::Policy::Modules::ProhibitModuleShebang π
β she lives in the User Contributed Perl Documentation, section 3pm (and yes, the header up top squishes her name down to Perl::...hebang(3pm) which is giving "mystery novel title" but it's literally this policy, iykyk π¦).
And what does she want from you? Simple. Don't put a #! line at the start of a module file. That's it. That's the whole gig. Periodt. π
πΈ DESCRIPTION πΈ
So this policy is part of the Perl::Critic::Pulp add-on π«Ά and she's asking you β politely, but with main character energy β not to use a #! interpreter line in a .pm module file.
Look at this mess:
#!/usr/bin/perl -w <-- bad
package Foo;
...
See that? bad π₯. The #! does literally nothing here, but it might make a reader think the file is supposed to be a program instead of a module. Confusing! Rude, even. π And ngl, most of the time that #! is just a leftover cut-and-paste from a script into a module β maybe you were grabbing a copyright notice or some similar intro and dragged the top line along with it. It happens. We've all been there. π
And of course β a module works exactly the same with or without it, so this policy is low severity and lives under the "cosmetic" theme (peep "POLICY THEMES" in Perl::Critic for the whole vibe check).
Now, important detail bestie: only the first line of a file counts as a prospective #! interpreter. A #! anywhere later is totally allowed β for example in code that generates other code:
sub foo {
print <<HERE;
#!/usr/bin/make <-- ok
# Makefile generated by Foo.pm - DO NOT EDIT
...
See? She said <green>ok</green>. We love a reasonable queen. π
Also: this policy applies only to .pm files. Anything else β like .pl or .t scripts β can have a #! or not, in the usual way, no judgement. Modules get identified by the .pm filename because honestly it's really hard to tell a module from a script just by looking at the content. Fr fr. π
π« Disabling π«
If you genuinely don't care about this (and like, valid), you can always disable "ProhibitModuleShebang" from your .perlcriticrc in the usual way (see "CONFIGURATION" in Perl::Critic):
[-Modules::ProhibitModuleShebang]
bye bestie, no hard feelings π
βοΈ CONFIGURATION βοΈ
allow_bin_false(boolean, defaulttrue) β when she'strue, you're allowed to have#!/bin/falsesitting in module files. Iconic exception.
#! /bin/false <-- ok
Why would you do this? Because that #! prevents the code from executing if it's accidentally run as a script π. Whether you actually want that is a personal preference, bestie β nobody's gonna fight you either way. It does signal "this is a module, not a script," which totally accords with what ProhibitModuleShebang is about, but ngl in general it's probably unnecessary. Cute touch though. π
π SEE ALSO π
- Perl::Critic::Pulp
- Perl::Critic
π HOME PAGE π
http://user42.tuxfamily.org/perl-critic-pulp/index.html π
π COPYRIGHT π
Copyright 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2019, 2021 Kevin Ryde
Perl-Critic-Pulp is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
Perl-Critic-Pulp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. π«‘
You should have received a copy of the GNU General Public License along with Perl-Critic-Pulp. If not, see http://www.gnu.org/licenses.
okay that's the whole page, bestie, you ate it up π
β¨ this one's running on perl v5.40.1 and it was last touched on 2025-10-21 β go forth and keep your modules shebang-free (unless it's #! /bin/false, in which case, werk) π¦ππ
π¦ where this page comes from
- ubuntu resolute: libperl-critic-pulp-perl 100-1 Β· GPL-3.0-or-later
- ubuntu stonking: libperl-critic-pulp-perl 100-1 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms