cpan tricks
Our beloved cpan
command line has some tricks up his sleave. In case you haven't read the fine CPAN manual in a while, let me point out some features I'm using right now to install all the needed modules for my day-to-day operation.
cpan .
You have a local directory with a module already unpacked, or your own personal module. The usual way to install them is doing the dance:
perl Makefile.PL
(manually deal with missing dependencies here)
make
make test
make install
The second step, the missing dependencies part, is the not so good part of the whole experience. Module::Build
authors and users would suggest that the first step is the really not so good part, but I digress.
A better way is to do:
cpan .
This will start a CPAN shell, and run the install process on the local directory, including fetching dependencies from you preferred CPAN site.
failed
command
Inside the shell, after you installed a long list of modules, the failed
command will list all the modules that failed the tests and did not install.
o conf init /REGEXP/
The command o conf init
will go through the entire configuration process. In recent versions it has become a long process and one of the things I tweak from time to time, the URL list of CPAN mirrors, is the last item asked.
To speed up the process you can o conf init /urllist/
and only configuration options matching urllist
will be asked.
Don't forget to o conf commit
at the end.
The smart CPAN urllist
The urllist
parameter lists the CPAN mirror sites that the shell will try to use to fetch the packages.
My favorite site is a local CPAN::Mini mirror, the best 750Mb used space I have on my systems. It allows me to install any module from CPAN even when I'm offline.
But this requires that I keep updating the mirror, and sometimes, I just forget. And I don't want to cron
it because I don't want to run it while I'm connected via UMTS.
A trick here is to set urllist
to several CPAN mirrors in your country and include your local CPAN::Mini mirror at the end with a file:
URL.
CPAN is smart and will fetch the CPAN indexes from one of the sites (see o conf init /random/
for some fun) but will always try to download the actual package from the file:
url first.
So you get up-to-date indexes for free.