You should generally prefer to use distribution package mangement for Perl modules on Linux where possible, but sometimes the module you need isn't carried, you're using a different version of perl (maybe via perlbrew), etc. So you need to install with CPAN, and you probably need to automate it for use in Docker, Vagrant, AWS, etc.
There's a dedicated tool for this, cpanminus or cpanm. It can be installed directly without needing CPAN already set up, per the docs linked above.
Many distribution package management systems carry cpanminus too.
The wonderful perlbrew tool knows how to install cpanminus silently into its managed environment with
perlbrew install-cpanm
so you don't need to mess with PERL_MM_USE_DEFAULT
, Perl scripts that use CPAN
and configure it directly, expect
scripts, manually creating files in ~/.cpan
, etc.
Once cpanm is installed you can just
cpanm install IPC::Run
or whatever, and it runs with no fuss.