Creating Perl Modules

A couple of notes to build a Perl Module.

using the module with the require function:

Using the module with the Use function

The difference between the two approaches is that use imports the symbols into the local namespace, so you don’t have to use the namespace anymore.

Making a module

Using the h2xs utility that comes along with PERL

      -A omits the Autoloader code (best used by modules that define a large number of infrequently used subroutines)
      -X omits XS elements (eXternal Subroutine, where eXternal means external to Perl, i.e. C)
      -n specifies the name of the module

The module can be tar and shipped.
To install the module:

This will produce following result

Leave a Reply

Your email address will not be published. Required fields are marked *