Teach Makefile.PL to use cpanm
I like to keep my perl modules lean when it comes to dependencies. But then again, CPAN is just so wonderful with all the helpful packages available. So there are always dependencies.
When writing perl modules, more often than not a few dependencies creep in … which makes it a whee bit awkward when developing the module, because I then have to somehow install these dependencies, and I would rather not get them all over the place but neatly in the module directory so that I have at least a semblance of a stable development environment.
So here goes my solution: A little postamble method for my Makefile.PL.
The postamble method gets called when you run
and adds its return value to the bottom of the generated Makefile, providing a new target named 3rd.
You can now call
to install all missing dependencies into the 3rd directory. The new rule uses cpanm to recursively download and install all the dependencies.
To let perl know where to find these modules, either set
while working on your module, or add
use lib "$FindBin::RealBin/../3rd/lib/perl5";
to your scripts, so that they can find the required modules.