passing installation parameters to cpan

To fix a failing
#cpan DBD::Oracle
complaining about missing header files, you can specify the INCLUDE location like the following

#cpan <<< "
o conf makepl_arg '-h /opt/oracle-client-11/sdk/include/'
install DBD::Oracle


With “o conf makepl_arg” we’ re just telling which parameters to pass to
#perl Makefile.PL

Obviously each module has its own 😉

A jar of Perl: PAR – II : repacking

After reading the previous post on PAR, you may want to unpack, modify and repack an existing PAR application.

Let’s play the game with a ficticious my-perl-webapp.bin

= First: unpack and analyze =

#mkdir /tmp/tmpdir/;
#unzip my-perl-webapp.bin -d /tmp/tmpdir/;
# cd /tmp/tmpdir

In tmpdir we’ll find:
the usual ./script/ directory with all the perl files run by the application;
the auto-generated by par;
the MANIFEST and META.yml files;
the ./lib/ directory with all the dependencies.

= Second: modify whatever =

Now you have all the perl files and you can modify and fix whatever you want.
Check and test before rebuild!

= Third: repack (simple) =

The first time we’ll try to repack with a simple:

# pp -P -o /tmp/my-perl-webapp-1.bin script/{all .pl files but } ;

Remember that is auto-generated by PAR.
When everything is done, check if all the dependencies have been added (ex. confronting package content with unzip -t)

= Fourth: repack (working) =

Repacking may require some more work. The pp command may not notify all the required dependencies you need.
You can check the MANIFEST for a list of files to add to your package.

Add to the package all the files present in the original one. You can do it with

# pp -a lib/ -a lib/ … -P -o …

To speed up things we’ll use find:

# find lib -type f -printf ” -a %p ” | \
xargs pp -P \
-o /tmp/my-perl-webapp-1.bin \
script/{all .pl files but }
-a META.yml

If you don’t remember how find -printf works you can check #man


A jar of perl…PAR

PAR is a way to distribute packed perl applications in executable format. Something like jar files for java, but in a platform dependant way. A par file contains all the nested dependencies of a perl script and a par executor.

Shortly, let’s create a perl script

# cat <
use Data::Dumper;
my %hash = (“a”=>1, “b”=>2);
print “hash: [“. Dumper(%a).”]”;

an make it an executable file with pp – the par packager:

# pp -o sample.bin

Now we get a binary executable file – sample.bin – containing all the dependencies (Data::Dumper) packed as a zip file.

# ll sample.bin;
-rwxr-xr-x 1 rpolli rpolli 3.1M 2012-07-26 10:15 sample.bin

We can really unzip it (but can’t modify wit zip -u or -g) watching the anatomy of the PARchive.

# unzip -t sample.bin
script/ <- our script file

lib/Data/ <- explicit dependecy

lib/File/ <- implicit dependency

Together with the deps we have:
a file used internally by par
a MANIFEST and META.yml with packaging info

PARchives can still be create as a perl script, saving some space:

# pp -P -o
# ll -h
-rwxr-xr-x 1 rpolli rpolli 25K 2012-07-26 10:28

Next time we’ll see how to unpack and repack a PAR file…