Module Creation Cookbook

The steps to create a simple module can be summarized as follows:

1.
Run h2xs to create the module directory:
h2xs –n mt_op
2.
Copy the header files into the directory you just created:
cp mt_op.h mt_op
3.
Run h2xs again, to create the prototype module files:
h2xs –Oxn mt_op mt_op.h
4.
If you require anything special in your build environment, edit the file
Makefile.PL.
5.
Edit the README file and put in proper documentation on how to build and install the module.
6.
Edit the module file (.pm file) so that the POD section documents your module.
7.
Edit the module file (.pm file) and put the names of the functions you want to export by default in the @EXPORT list.
8.
Edit the external subroutine (.xs file) ...

Get Perl for C Programmers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.