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

Is there a way to invoke cpanp (e.g. from a perl script) so that it will install a list of modules, automatically add any prerequisites that are missing, and abort if it can't find one or more prerequisites?

Replies are listed 'Best First'.
Re: cpanp scripting
by juster (Friar) on Mar 01, 2009 at 09:09 UTC

    You can use the simplified CPANPLUS module interface, or CPANPLUS::Backend, the object-oriented way.

    # Simple version use CPANPLUS; for my $mod (qw/Acme::Drunk Acme::Bleach/) { install($mod); } # Complex version, probably better use CPANPLUS::Backend; my $cb = CPANPLUS::Backend->new(); $cb->install( modules => [ 'Acme::Drunk', 'Acme::Bleach' ] );

    CPANPLUS installs prerequisites automatically, provided you have the configuration option 'prereqs' set to 1.

Re: cpanp scripting
by Anonymous Monk on Mar 01, 2009 at 06:40 UTC
    Yes, use
    system 'cpanp', '--install', '--prereqs',... 'Foo::Bar'