How to reconfigure CPAN

I found this to be quite a vexing problem: how do I reconfigure CPAN completely, to fetch CPAN packages from the mirror closest to me?

(If you are unfamiliar with CPAN, please stop reading right now, as too much knowledge in the hands of newbies is dangerous indeed...) ;-)

Turned out to be simple enough:

# perl -MCPAN -eshell

cpan shell -- CPAN exploration and modules installation (v2.00)
Enter 'h' for help.

cpan[1]> o conf init

[... Some output removed here ...]

cpan[2]> o conf init urllist

Now you need to choose your CPAN mirror sites.  You can let me
pick mirrors for you, you can select them from a list or you
can enter them by hand.

Would you like me to automatically choose some CPAN mirror
sites for you? (This means connecting to the Internet) [yes] y

Trying to refresh your mirror list
Fetching with LWP:

Looking for CPAN mirrors near you (please be patient)
.....................Use of uninitialized value $ping_cache_limit in numeric gt (>) at /usr/lib/perl5/5.16.2/CPAN/ line 384.
... done!

New urllist

Please remember to call 'o conf commit' to make the config permanent!

cpan[3]> o conf commit
commit: wrote '/root/.cpan/CPAN/'

And... You are done! Easy enough right?

As a bonus feature, remember that CPAN can be upgraded easily with:

cpan> upgrade CPAN
cpan> reload CPAN

And that's all for now...

See Also: