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, default true) β€” when she's true, you're allowed to have #!/bin/false sitting 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 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