CPAN is THE killer feature for Perl. One problem you may have from time to time due to it’s online nature is availability issues. How do you install CPAN modules from a plane, train, or automobile without wifi? Or from the middle of nowhere in Oregon (Ione, OR)? Or timely install Moose and it’s dependencies from a dial-up connection in the middle of the deserted Oklahoma plains (Leedey, OK). Well, my fellow perler, I have been to these places forgotten by the Internets, and I have installed CPAN modules with impunity.
CPAN::Mini, driven by the included minicpan, creates a local mirror of CPAN containing only the latest non-developer release of every distribution on CPAN. With CPAN::Mini you too can install CPAN modules with impunity from exotic locations. But just how much disk space must you dedicate for such awesomeness? My mirror is currently just under 3 GB.
Start by installing CPAN::Mini with your CPAN client of choice:
1 2 3 4 5
Now you need a config file in
1 2 3 4
These options should be fairly self-explanatory. Check out the
CPAN Mirrors site to find a healthy mirror in your region
for the second line. Now, just run
minicpan and wait. Periodically,
you’ll want to run this command again to download new dists and delete old ones.
That’s all it takes to be the owner of a shiny tiny local CPAN mirror.
Using Your Shiny New CPAN Mirror
To use your new mirror, just specify the path to your CPAN::Mini mirror in your CPAN client of choice.
For cpanm I
have an alias in my
The same line should work in a
.bashrc as is. Then, to install a new CPAN
module, just run
cpanp s edit and your editor will launch. If the file you are in
isn’t empty, skip to the next step. Now run
cpanp s save to copy the
current configuration to the user config file and then run
cpanp s edit
hosts config and add your new entry at the beginning.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Save and exit your editor.
cpan, you use the interactive shell to update the configuration:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Enjoy (Faster) CPAN Installs From Anywhere
That’s it! From here on out your disk speed and not your Internet connection, or lack thereof, will be your throttle in your CPAN client of choice acquiring distribution packages.