#!/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.] } #### 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, 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.] }' }