I can't find the answer to this anywhere: Does a module installed via APT conflict with one installed via CPAN?
Along with that question are these: Where do the installed CPAN modules live? Are they accessible globally or just to the installing user? How do you know which one? How do you know what's installed and which takes precedence?
Should CPAN even be used when modules are installed via APT?
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:
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.
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.
You can use both but they will conflict. They're written to the same place so if you install something from apt and then install a later version from cpan, you could bodge things up.
I don't do much Perl but in Python I certainly have the dilemma you're talking about: apt-vs-PyPI. I personally opt for apt whenever I can. It means I should get updates without having to remember to maintain each individual Python package. Not only that but it means that all my systems should be running on the same version of those packages.
It doesn't always work out. Sometimes you don't have new enough things in the repos or something you need just isn't packaged up. Neither way is perfect but I believe apt to be more perfect. Just be aware of what you're doing and you should be okay.
Edit - Almost forgot, there is a better way to section things up so the system can have its own environment and whatever you're developing can live in its own environment (that you manage completely with CPAN), Like Python's
virtualenv
...https://stackoverflow.com/questions/1423879/how-can-i-install-specialized-environments-for-different-perl-applications