Ubuntu allows you to add and remove components from your system using apt-get. Perl allows similar functionality for maintaing Perl modules through the CPAN module’s shell (invoked by perl -MCPAN -eshell). Now if you are just going to add a Perl module to your system, should you be using apt-get or CPAN?
I prefer to use apt-get because this allows me to keep track of everything I’ve added to my system in one place. It also keeps things neat in case a given Perl module has binary dependencies. For 99% of the cases, I’ve found an apt package equivalent of a given CPAN module. The naming convention of the modules varies between CPAN and apt. For example, the package Algorithm::Diff at CPAN, is known as libalgortihm-diff-perl in the apt world.
So sometimes the trick is knowing the correct apt name for a CPAN module. Now in most cases, if you know the Perl name of a module – say XML::Simple then you can arrive at the apt name by converting the package name to lowercase, replacing the “::” with a “-”, prefixing “lib” and suffixing -perl to it. i.e.
echo "XML::Simple" | perl -e '$x=<>; chomp($x); $x=~s/::/-/; $x=lc($x); print "lib$x-perl"'
And if you want to automate things further:
sudo bash
echo "XML::Simple" | perl -e '$x=<>; chomp($x); $x=~s/::/-/; $x=lc($x); print "lib$x-perl"' | xargs apt-get install
Just bear in mind that there are exceptions to this naming convention. The one I ran into recently involved Sablotron; which is known as XML::Sablotron in the CPAN world, but as libxml-sablot-perl in the apt world.
Also, apt might not always have the most recent version of a given module. So you have to depend on CPAN if you need the latest, greatest version of a module.
Lastly, some modules might not have an apt version – for example at the moment Devel::PerlySense exists on CPAN alone.