Creating a Perl Module
Creating a Perl Module Organic Design procedure |
A Perl module is essentially just a .pm file which has a specific structure allowing it to extend the native Perl runtime environment to add new namespaces, objects and subroutines etc. The .pm structure also allows for automatically generated documentation.
Create package skeleton
To ensure that the module is added to the operating system environment properly, it should be wrapped into a package so that it can be installed with make and make install in the usual way. We use the h2xs utility.
h2xs -XAn OrganicDesign::Example
This will create a working structure which can be installed and then included in a Perl script with use OrganicDesign::Wiki.
Modify the module file
In the directory structure created by h2xs is a subdirectory called lib which contains a template .pm module file which can be refined and extended to your needs. Generally the first thing to do would be to add comments at the beginning describing the module, and edit the documentation section at the end. Then create a constructor and other required methods. See OrganicDesign::Wiki.pm for an example of one of our modules.
Updating the package
Dunno how to do this properly yet