http://www.perlmonks.org?node_id=548581

dsheroh has asked for the wisdom of the Perl Monks concerning the following question:

I really didn't want to have to ask this question here, as it seems like something that should already have a well-known solution, but neither google nor super search was able to find such a solution for me. So...

I need to distribute a few CPAN modules to approximately 100 hosts, some of which already have CPAN configured, but most do not. According to the CPAN documentation at http://search.cpan.org/~andk/CPAN-1.87/lib/CPAN.pm:

How do I install a module and all its dependencies from the commandline, without being prompted for anything, despite my CPAN configuration (or lack thereof)?

CPAN uses ExtUtils::MakeMaker's prompt() function to ask its questions, so if you set the PERL_MM_USE_DEFAULT environment variable, you shouldn't be asked any questions at all (assuming the modules you are installing are nice about obeying that variable as well):

% PERL_MM_USE_DEFAULT=1 perl -MCPAN -e 'install My::Module'
Unfortunately, this is not reliably the case, as several of the hosts I've tested this against have gotten themselves stuck in an endless loop due to "Select your continent (or several nearby continents)" defaulting to an empty response, which is not valid. (So much for the claim that it will work "despite my CPAN configuration (or lack thereof)"...)

My next idea was to copy CPAN/Config.pm to each host and just duplicate a single good configuration on all of them, but that sits inside a version-specific subdirectory and the hosts in question are not all running the same version of perl, so that doesn't appear to be a strong candidate for automation either.

What other options do I have for getting all of these hosts configured for CPAN without having to touch each one manually to tell it "no, I don't want to do manual configuration, so just go ahead and pick some default values instead"?