Sat, 29 Apr 2006
I wanted to build a local CPAN mirror using CPAN::Mini. Since it takes a little time to download all that data I wanted to choose a nice fast mirror. This little command was helpful:
$ netselect -vv `wget -O - http://www.cpan.org/SITES.html | \ perl -lne 'print $1 while m!>((ht|f)tp://[^<]+)!g'` | \ sort -k 4 -n
It grabs the CPAN mirrors file, extracts the URLs and feeds them to netselect, which tests the mirrors and outputs its information. This is then sorted numerically on the fourth field, which is the number of hops.
The sorting is necessary because although netselect does tell you which mirror it thinks is the best, it doesn't really select very well. In fact, some of its output seems downright dodgy, so I selected a mirror which seemed plausibly fast, close and reliable. For me that was http://cpan.wanadoo.nl/.
For useful information on using CPAN::Mini, take a look at Mark Fowler's 2004 Perl Advent Calendar. You might need to get that from the Wayback Machine at http://web.archive.org/web/20060214214713/http://perladvent.org/2004/5th/ (which is another URL kwiki has managed to mangle).