logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Perl::Critic::Policy::Modules::ProhibitModuleShebang - don't put a #! line at the start of a module file

Configuration

       "allow_bin_false" (boolean, default true)
           If true then allow "#!/bin/false" in module files.

               #! /bin/false           <-- ok

           Such  a "#!" prevents executing the code if accidentally run as a script.  Whether you want this is a
           personal  preference.   It  indicates  a   module   is   not   a   script   and   so   accords   with
           "ProhibitModuleShebang", but in general it's probably unnecessary.

Description

       This policy is part of the "Perl::Critic::Pulp" add-on.  It asks you not to use a "#!" interpreter line
       in a .pm module file.

           #!/usr/bin/perl -w      <-- bad
           package Foo;
           ...

       This "#!" does nothing but might make a reader think it's supposed to be a program instead of a module.
       Often the "#!" is a leftover cut and paste from a script into a module, perhaps when grabbing a copyright
       notice or similar intro.

       Of course a module works the same with or without, so this policy is low severity and under the
       "cosmetic" theme (see "POLICY THEMES" in Perl::Critic).

       Only the first line of a file is a prospective "#!" interpreter.  A "#!" anywhere later is allowed, for
       example in code which generates other code,

           sub foo {
             print <<HERE;
           #!/usr/bin/make         <-- ok
           # Makefile generated by Foo.pm - DO NOT EDIT
           ...

       This policy applies only to .pm files.  Anything else, such as ".pl" or ".t" scripts can have "#!", or
       not, in the usual way.  Modules are identified by the .pm filename because it's hard to distinguish a
       module from a script just by the content.

   Disabling
       If you don't care about this you can always disable "ProhibitModuleShebang" from your .perlcriticrc in
       the usual way (see "CONFIGURATION" in Perl::Critic),

           [-Modules::ProhibitModuleShebang]

Home Page

Name

       Perl::Critic::Policy::Modules::ProhibitModuleShebang - don't put a #! line at the start of a module file

See Also

       Perl::Critic::Pulp, Perl::Critic

See Also