CPAN vs. APT: Conflicts in versions?

Solution 1:

On Debian and Ubuntu CPAN (/usr/bin/cpan utility) installs modules into /usr/local/lib/ by default. And debian packages keep their files in /usr/share/perl5/ and /usr/lib/perl5/. So files installed via /usr/bin/cpan won't overwrite files installed via apt.

There's nothing wrong with using system perl, and mixing apt and cpan code will generally work.

You can also choose to package any cpan distribution not available in your apt repositories manually. It's easy with the help of dh-make-perl tool:

dh-make-perl --cpan Some::Module && cd Some-Module* && sudo debi

Solution 2:

I use perlbrew. It installs a local version of Perl and cpan. Everything it does is done in your home directory. It's straight forward to install and use and you can install the latest version of Perl.

Solution 3:

When installing from CPAN directly I would recommend using local::lib to a directory private to you. See the boostrapping technique https://metacpan.org/module/local::lib

That way the CPAN installed module will be only used by your user and it will have a very clean separation from the modules installed using APT.

It will also make it easy to get rid of the CPAN-installed modules if you encounter any issue or when you upgrade Ubuntu.

That's how I use it on Ubuntu.