I've got some code that is not a direct answer to your question but addresses a related concern that CPAN users should have. It regards the freshness of the list of mirrors which gets stored locally when the CPAN setup (init run) first takes place. Due to what I consider a misdesign or missing feature of CPAN, that file is never checked for staleness; thus if you do rerun a setup (cpan> o conf init) some time, you will be presented with a list of mirrors to choose from that may miss some good, recently-added ones that you'd want, or include some now bogus, decommissioned ones that have had their virtual plugs pulled.

I use this as a shell (bash) function which I run when I feel like it. A more automation-oriented person would likely want to make it into a cron job or something similar.

#!/usr/bin/env perl use File::stat; use CPAN; use LWP::Simple ("mirror"); use warnings; use strict; CPAN::Config->load; my $fhost; my $mbdata = $CPAN::Config->{keep_source_where}.q[/MIRRORED.BY]; if (-e $mbdata and -M _ < 14) { print qq[$mbdata: freshness is OK, it was last modified: ] . gmtime stat($mbdata)->mtime() } else { ($fhost)=grep(/^http/,@{$CPAN::Config->{urllist}}); die "No suitable cpan http mirror host, aborting. Sorry." unless $ +fhost; printf qq[%s\n%s\n] , qq[File $mbdata not found, or local file may be stale.] , qq[will d/l fresh MIRRORED.BY file from $fhost, please wait +...]; mirror($fhost .q[MIRRORED.BY] , $mbdata) and print q[New MIRRORED.BY file timestamp in UTC: ] . gmtime(stat($mbdata)->mtime) .qq[\n] or die qq[Retrieval of MIRRORED.BY from $fhost FAILED. Sorry +.] }

Here's the bash-wrapped form of the same code:

function freshen_MIRROREDBY { perl -MFile::stat -MCPAN -MLWP::Simple=mirror -le ' CPAN::Config->load; my $fhost; my $mbdata = $CPAN::Config->{keep_source_where}.q[/MIRRORED.BY +]; if (-e $mbdata and -M _ < 14) { print qq[$mbdata: freshness is OK, last modified: ] . gmtime stat($mbdata)->mtime() } else { ($fhost)=grep(/^http/,@{$CPAN::Config->{urllist}}); die "No suitable cpan http mirror host, aborting. Sorry." +unless $fhost; printf qq[%s\n%s\n] , qq[File $mbdata not found, or local file may be stale +.] , qq[will d/l fresh MIRRORED.BY file from $fhost, pleas +e wait ...]; mirror($fhost .q[MIRRORED.BY] , $mbdata) and print q[New MIRRORED.BY file timestamp in UTC: ] . gmtime(stat($mbdata)->mtime) . qq[\n] or die qq[Retrieval of MIRRORED.BY from $fhost FAIL +ED. Sorry.] }' }

I hope this is useful to someone. I don't dare hope that the numerous anal among the Perlmonks readership won't punish the posting of code as usual by finding some petty style mistakes to justify a bitchy downvote orgy.


In reply to Re: What Does CPAN Mirror "Freshness Date" Mean? by Intrepid
in thread What Does CPAN Mirror "Freshness Date" Mean? by awohld

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.