I want a shell script that will find the directory where perl is installed in local system, open that perl, and install all the CPAN modules automatically.
Asked
Active
Viewed 1,198 times
2 Answers
4
I think cpanminus is what you are looking for.
You can install modules like this:
cpanm Dancer Dancer::Plugin::Database (etc. etc.)
It will install these modules with all dependencies.

Demnogonis
- 3,172
- 5
- 31
- 45
-
cpanm is command line application to manage modules and also it is module for managing from script. – Pingwin Tux Feb 11 '14 at 10:08
0
If you are installing a module and want all of it's dependencies, just tell the cpan
command the module you want and it takes care of the rest.
% cpan Some::Module
The utilities that comes with perl
already know where perl
is because they adjust their shebang line to be the perl
that installed them. They'll get all the settings from that perl
when it starts.
If you want to use some other perl
, run cpan
with that perl
. Now all the settings come from /my/other/perl
.
% /my/other/perl `which cpan` Some::Module
Additionally, you can dump the cpan
settings with -J
, fiddle with them, and load them for a single run of cpan
:
% cpan -J > settings.dump
...adjust settings...
% cpan -j settings.dump

brian d foy
- 129,424
- 31
- 207
- 592