---
name: "Perl::Critic::Policy::Community::PackageMatchesFilename"
section: "3pm"
platform: "linux"
package: "libperl-critic-community-perl"
version: "1.0.4-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Perl::Critic::Policy::Community::PackageMatchesFilename"
---

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

Module files should declare a package matching the filename

## NAME

Perl::Critic::Policy::Community::PackageMatchesFilename - Module files should declare a package matching the filename

## DESCRIPTION

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.

## AUTHOR

Dan Book, `"dbook@cpan.org"`

## COPYRIGHT AND LICENSE

Copyright 2015, Dan Book.

This library is free software; you may redistribute it and/or modify it under the terms of the Artistic License version 2.0.

## SEE ALSO

Perl::Critic
