PM - Perl Module
In this tutorial, we are going to study everything about (pm) perl module.
A (pm) Perl Module is a block of code which can be used in a perl program or in a module itself. Perl module should have unique names for eliminiating confusion and maintaining the consistency.
Refrences:
Perl Cookbook
Lets run the first command which will make a directory name 'Utils'
Run the following command
h2xs -b 5.6.1 -AX Utils
Output
Writing Utils/lib/Utils.pm
Writing Utils/Makefile.PL
Writing Utils/README
Writing Utils/t/Utils.t
Writing Utils/Changes
Writing Utils/MANIFEST
Now change the directory cd Utils/ & look for README file for License Information.
COPYRIGHT AND LICENCE
Put the correct copyright and licence information here.
Copyright (C) 2010 by root
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.8 or,
at your option, any later version of Perl 5 you may have available.
1.To build a Perl module. Go to the Utils directory and run the following command as shown below.
cd Utils
perl Makefile.PL (Since there is no interpreter in the perl script.)
Output
Checking if your kit is complete...
Looks good
Writing Makefile for Utils
2. Now Compiling the code, using make command.
make
Output
cp lib/Utils.pm blib/lib/Utils.pm
Manifying blib/man3/Utils.3pm
3. Now, the below command will test the (pm) perl module build.
make test
Output
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/Utils....ok
All tests successful.
Files=1, Tests=1, 0 wallclock secs ( 0.00 cusr + 0.02 csys = 0.02 CPU)
4. The next command will install the (pm) perl module.
make install
Output
Installing /usr/lib/perl5/site_perl/5.8.8/Utils.pm
Writing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/Utils/.packlist
Appending installation info to /usr/lib/perl5/5.8.8/i386-linux-thread-multi/perllocal.pod
Now the pm perl module is installed and availabe to everyone on the system.
5. Now we will package the module into a zip file. This zip will work as a distribution which can be copied and installed on any system.
make dist
Output
rm -rf Utils-0.01
/usr/bin/perl "-MExtUtils::Manifest=manicopy,maniread" \
-e "manicopy(maniread(),'Utils-0.01', 'best');"
mkdir Utils-0.01
mkdir Utils-0.01/t
mkdir Utils-0.01/lib
Generating META.yml
tar cvf Utils-0.01.tar Utils-0.01
Utils-0.01/
Utils-0.01/t/
Utils-0.01/t/Utils.t
Utils-0.01/MANIFEST
Utils-0.01/lib/
Utils-0.01/lib/Utils.pm
Utils-0.01/Changes
Utils-0.01/Makefile.PL
Utils-0.01/META.yml
Utils-0.01/README
rm -rf Utils-0.01
gzip --best Utils-0.01.tar
pm - Perl module configuration & installation is completed successfully.
|