Bash – Silent and scripted install of CPAN and Perl modules

bashcpanperlshell-scripting

I need to install CPAN and some Perl modules automatically in a Scientific Linux (RHEL) installation script. Unfortunately the specific modules I want (at least one of them) cannot be found as RPM:s as far as I've seen.

So I need to install CPAN, configure it automatically (or with a config file) and then install the wanted modules (including dependencies) automatically as well.

This doesn't seem like a very unusual requirement, but I haven't seen any really good documentation on this. The problem is that whenever CPAN is launched for the first time an interactive configuration runs. Can this be skipped somehow? And how do I launch module installations directly from the command line?

Best Answer

You might want to look at cpanm for this; it's lightweight, shell scriptable, and much simpler than classic CPAN.