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?
Try setting this environment variable before running CPAN:
export PERL_MM_USE_DEFAULT=1
It makes perl automatically answer "yes" when CPAN asks "Would you like to configure as much as possible automatically? [yes]"
Source
"And how do I launch module installations directly from the command line?"
This should do:
If it's a repetitive task, it may pay to spend a few hours with cpan2rpm and turn them into RPM's. In my experience, CPAN runs (even interactive) are too plagued by unexpected events (version quirks, network problems, bogus tests failures) to be relied upon in a (semi-)automatic install.
You might want to look at cpanm for this; it's lightweight, shell scriptable, and much simpler than classic CPAN.
This should do the magic: