Ever wonder which CPAN mirror in your country is the most up to date? Just run this script, passing your two-letter country code on the command line, defaulting to 'us'. Requires XML::XSH2. The resulting output is sorted by age in hours. For Germany right now, we get:
ftp://ftp.uni-erlangen.de/pub/source/CPAN/ => 1 http://www.planet-elektronik.de/CPAN/ => 1 http://cpan.noris.de/ => 2 http://netmirror.org/mirror/CPAN/ => 2 ftp://cpan.mirror.iphh.net/pub/CPAN/ => 2 http://www.chemmedia.de/mirrors/CPAN/ => 3 ftp://ftp.fu-berlin.de/unix/languages/perl/ => 3 ftp://ftp.rub.de/pub/CPAN/ => 3 http://ftp.uni-erlangen.de/pub/CPAN/ => 4 ftp://netmirror.org/CPAN/ => 5 http://cpan.mirror.iphh.net/ => 6 http://cpan.provocation.net/ => 8 ftp://cpan.provocation.net/ => 8 ftp://cpan.noris.de/pub/CPAN/ => 10 ftp://ftp.gwdg.de/pub/languages/perl/CPAN/ => 11 http://dl.ambiweb.de/mirrors/ftp.cpan.org/ => 11 http://ftp.gwdg.de/pub/languages/perl/CPAN/ => 11 ftp://ftp.mpi-sb.mpg.de/pub/perl/CPAN/ => 11 http://www.couol.com/cpan/ => 12 ftp://ftp-stud.fht-esslingen.de/pub/Mirrors/CPAN/ => 12 ftp://ftp.cw.net/pub/CPAN/ => 13 http://ftp.cw.net/pub/CPAN/ => 13 ftp://ftp.gmd.de/mirrors/CPAN/ => 13 ftp://ftp.cs.tu-berlin.de/pub/lang/perl/CPAN/ => 13 http://cpan.triplemind.com/ => 14 ftp://ftp.freenet.de/pub/ftp.cpan.org/pub/CPAN/ => 15 http://cpan.mirroring.de/ => 15 ftp://pandemonium.tiscali.de/pub/CPAN/ => 16 ftp://nlp.petamem.com/ => 16 http://pandemonium.tiscali.de/pub/CPAN/ => 16 http://cpan.interprovide.de/ => 21 http://www.mirrorspace.org/cpan/ => 28 http://www.cpan.mirroarrr.de/ => 672 http://cpan.linux-mirror.org/ => 2224.8
Yes, that means that last mirror hasn't been updated in three months!

This code is for an upcoming Linux Magazine column.

#!/usr/bin/env xsh quiet; # open --format html 'cpan.html'; open --format html 'http://www.cs.uu.nl/people/henkp/mirmon/cpan.html' +; perl { $country = @ARGV ? shift(@ARGV) : 'us' }; for //tr[th/a/@name = $country]/following-sibling::* { if th/a/@name last; $url = (td[1]/a[1]/@href); $time = (td[3]); perl { $time{$url} = $time }; } perl { for (values %time) { s{([\d.]+) days?}{$1 * 24}e or s{([\d.]+) hours?}{$1} or s{([\d.]+) minutes?}{sprintf "%.1f", $1 / 60}e or die "Don't understand $_"; } for (sort { $time{$a} <=> $time{$b} } keys %time) { print "$_ => $time{$_}\n"; } }

In reply to Get most recently refreshed CPAN mirror in your country by merlyn

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.