Is there any preferred naming convention for perl modules?
For example, what is more common practice in perl world - SomeModule
or Some::Module
? Maybe there are some cases when one style is better than another?
If you take a look at CPAN you will see that, by and large, module names are organised into top-level categories for the first segment of the name, and a distinctive name within that category for each module. For instance, the top ten categories (by distribution count) are
Net
App
WWW
Test
Data
Catalyst
Acme
Text
Dist
HTML
The second part of the name is usually either to identify it within all other modules of that category (such as HTML::TreeBuilder
), or as a subdivision of a large category (like Net::FTP::*
modules)
There may be a third section to the name, which represents either a component module of an overall set (for example DBIx::Class::Relationship
and DBIx::Class::ResultSet
) or a separate module that has been subclassed from another (like HTML::TreeBuilder::XPath
)
For too long there has been no control over the names of the modules uploaded to CPAN, and some parts of it can be a bit of a mess. However it does represent a defined and growing set of names that you should try to avoid with your own package identifiers. Your example isn't very realistic, but I would probably go with just SomeModule
, as just inserting a pair of colons between every pair of words is definitely not the way to go
If you have multiple modules you can start gathering them together into categories, and it would help if you used a top-level category (like Site
or Company
) that avoided clashes with any CPAN modules that you could use. Examples could be Site::Utils::Matrices
and Site::Utils::StringProcessing
The one major rule is that your package names should be in CamelCase, as all lower-case names are reserved for Perl pragmas
Since stevieb's solution has been deleted, it's worth me reposting a link to brian d foy's excellent On The Naming of Modules which makes many salient points