A Perl module is a self-contained block of software which can be plugged into your programs to give you instant access to a specific set of functionality. Conventionally, Perl modules are stored in files with a .pm extension, with exactly one module per file. Each module should have a unique namespace, signified by a line like:
or whatever namespace you are using.
It is also conventional to have a line such as
our $VERSION = "1.0";
to set the
$ModuleName::VERSION variable, which is necessary for some forms of the
use statement. Finally, most modules have a lone
1; statement at the end of the file to return a boolean true value signifying that the module has been successfully initialized. Some modules that run code to set themselves up can return a false value (0) if they encounter problems.
While many modules are packaged with documentation files, it is common to see POD-style documentation within the module file as well.
To access a module's functionality in a program, simply include the line
Foo::Bar is the namespace of the appropriate module. Your Perl interpreter will need to be able to find the appropriate module file, of course; you should consult the interpreter's own manual if you experience problems with this.
Modules for almost any purpose under the sun can be found on CPAN