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

I would like to write a script which will install perl Modules, It works successfully on a machine where manualconfiguration is already done, but on the machine where cpan is used for first time it fails.

Can any one let me know how to skip this?
  • Comment on How to skip the prompt fot configuring CPAN.

Replies are listed 'Best First'.
Re: How to skip the prompt fot configuring CPAN.
by Khen1950fx (Canon) on Mar 01, 2011 at 05:51 UTC
      disclaimer: I have since discovered cpanm and decided that it is preferable to hacking cpan config files.
Re: How to skip the prompt fot configuring CPAN.
by Eliya (Vicar) on Mar 01, 2011 at 06:07 UTC

    You could also try copying your ~/.cpan directory - in particular the ~/.cpan/CPAN/MyConfig.pm file - from a machine where the initialization has already run, to the machines where it hasn't (into the home of the user who does the automated installations).

    See also mkmyconfig

Re: How to skip the prompt fot configuring CPAN.
by Khen1950fx (Canon) on Mar 01, 2011 at 21:31 UTC
    I did some experimenting with App::cpanminus. I took a cpan script and used cpanm. The script fetchs and installs App::cpanminus, and then it installs all the prerequisites for Moose and Moose itself without the need for cpan. Warning: take a coffee break while Moose installs if you choose to try it:).
    #!/usr/bin/perl use strict; use warnings; system("curl -L http://cpanmin.us | perl - App::cpanminus"); exec( "cpanm", "namespace::clean", "namespace::autoclean", "Class::MOP", "Eval::Closure", "Declare::Constraints::Simple", "Package::DeprecationManager", "Sub::Name", "Test::Fatal", "Dist::CheckConflicts", "Data::OptList", "Devel::GlobalDestruction", "List::MoreUtils", "MRO::Compat", "Params::Util", "Scalar::Util", "Sub::Exporter", "Task::Weaken", "Moose", "MooseX::Role::WithOverloading", "Package::Stash::XS", "Package::Stash");
    Note: you might need to use --sudo