Creating Perl Modules

Document Sample
Creating Perl Modules Powered By Docstoc
					Creating Perl Modules

      Oct 6th, 2004
               Perl Modules
•   Perl files which have .pm extension
•   Easier to bundle, distribute
•   Easier to test
•   Easier to install
•   Easier to develop
                 Development
• Create a directory for you module
  – Example:
     • Module Apache::Filter
        – Filter.pm is on directory Apache/Filter/
     • Our Project might be Network::Router,
       Network::Host, Network::Link
        – Link.pm is in Network/Link/
        – Host.pm is in Network/Host/
        – Router.pm is in Network/Router/
    Creating Module Skeleton
• Command line util: h2xs
     mary-kate ~/dave: h2xs -AXc NewModule

     Writing NewModule/NewModule.pm
     Writing NewModule/Makefile.PL
     Writing NewModule/README
     Writing NewModule/t/1.t
     Writing NewModule/Changes
     Writing NewModule/MANIFEST
       Installing your module
• The general procedure for installation:

     perl Makefile.pl
     make
     make test
     make install