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"?


In reply to Automating CPAN Configuration by dsheroh

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.