Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I automate CPAN configuration?

Tags:

perl

cpan

The first time you run cpan from the command line, you are prompted for answers to various questions. How do you automate cpan and install modules non-interactively from the beginning?

like image 641
runrig Avatar asked Aug 11 '10 19:08

runrig


People also ask

What is CPAN command?

"cpan" splits this variable on whitespace and prepends that list to @ARGV before it processes the command-line arguments. For instance, if you always want to use "local:lib", you can set "CPAN_OPTS" to "-I".

What is the difference between CPAN and cpanm?

The main difference between the two is that if you have Perl you should already have the cpan command. Whereas you won't have cpanm unless/until you install it.

Where does CPAN install to?

CPAN doesn't actually install files. It runs the install script embedded in each distribution, which then performs the actual install. For distributions using ExtUtils::MakeMaker, the defaults are documented here: https://metacpan.org/pod/ExtUtils::MakeMaker#make-install (and the default value of INSTALLDIRS is site ).


2 Answers

Since it hasn't been mentioned yet, cpanminus is a zero-conf cpan installer. And you can download a self-contained executable if it isn't available for your version control.

The cpanm executable is easily installed (as documented in the executable itself) with:

curl -L http://cpanmin.us | perl - --self-upgrade # or wget -O - http://cpanmin.us | perl - --self-upgrade 
like image 126
phaylon Avatar answered Sep 29 '22 23:09

phaylon


I was looking for an easy solution for this as well and found that this works:

(echo y;echo o conf prerequisites_policy follow;echo o conf commit)|cpan 

Just thought I would post it here in case anyone else comes along.

like image 35
Clayton Dukes Avatar answered Sep 29 '22 23:09

Clayton Dukes