Tuesday, December 14, 2010

Install Perl Modules

This is really my personal memo.
I have installed a perl module for the first time in my life and actually learned a lot, so just like to keep what I did here for future reference.

The command is as simple as this. There is a switch -MCPAN for the executable itself to add a module. I log the output. Again this is just for my reference.
# perl -MCPAN -e "install Time::Period" >install.perl.time.period.log 2>&1

Actually, this failed.
It was unable to find the package, Period-1.20.tar.gz, at (in our environment)
http://cpan.mirror.fr/.
I found the file at
http://search.cpan.org/CPAN/authors/id/P/PR/PRYAN/Period-1.20.tar.gz. So how can I change the host (that perl goes to get packages)? You do as follows.

# perl -MCPAN -e shell <- go into the shell mode

cpan shell -- CPAN exploration and modules installation (v1.61)
ReadLine support available (try 'install Bundle::CPAN')

cpan> o conf urllist <- show the currect host list

urllist
http://cpan.mirror.fr
http://cpan.mirror.fr/
Type 'o conf' to view configuration edit options

cpan> o conf urllist pop
cpan> o conf urllist pop <- do this twice to remove the unwanted hosts


cpan> o conf urllist push http://search.cpan.org/CPAN/
cpan> o conf urllist push http://cpan.mirror.fr <- not really care but just liked to keep what were there
cpan> o conf urllist push http://cpan.mirror.fr/

cpan> o conf urllist
urllist
http://search.cpan.org/CPAN/ <- now perl tries this site first
http://cpan.mirror.fr
http://cpan.mirror.fr/
Type 'o conf' to view configuration edit options

cpan> o conf commit
commit: wrote /usr/lib/perl5/5.8.0/CPAN/Config.pm

cpan> quit

Try the first command again, and GOTCHA!

No comments: