Perl::Critic::Policy::Community::PackageMatchesFilename(3pm)

Perl::Critic::Policy::Community::PackageMatchesFilename3pm

Module files should declare a package matching the filename

Overview

Perl modules are normally loaded by "require" (possibly via "use" or "no"). When given a module name, "require" will translate this into a filename and then load whatever that file contains. The file doesn't need to actually contain a package matching the module name initially given to "require", but this can be confusing if later operations (including "import" as called by "use") expect the package to exist. Furthermore, the absence of such a package is usually an indicator of a typo in the package name.

  ## in file My/Module.pm
  package My::Module;

This policy is similar to the core policy Perl::Critic::Policy::Modules::RequireFilenameMatchesPackage, but only requires that one package name within a module file matches the filename.

Affiliation

This policy is part of Perl::Critic::Community.

Configuration

This policy is not configurable except for the standard options.

Releases

2 releases since Debian 12 (Bookworm); the text changed 1 time.

  1. 12
  2. 13

Author

Dan Book, "[email protected]"

From libperl-critic-community-perl 1.0.4-1 in Debian 13 (Trixie). Parsed by carta from the page's man source.