Sat, 29 Apr 2006

Fast CPAN mirrors

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 - | \
  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

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 (which is another URL kwiki has managed to mangle).

[/software/perl] permanent link

February 2022
Sun Mon Tue Wed Thu Fri Sat