How do I create a module?

A module is a package that lives in a file of the same name. For example, the Hello::There module would live in Hello/There.pm. For details, read perlmod. You'll also find Exporter helpful. If you're writing a C or mixed-language module with both C and Perl, then you should study perlxstut.

The h2xs program will create stubs for all the important stuff for you:

  % h2xs -XA -n My::Module
The -X switch tells h2xs that you are not using XS extension code. The -A switch tells h2xs that you are not using the AutoLoader, and the -n switch specifies the name of the module. See h2xs for more details.
Back to perlfaq7