use Time::HiRes;
use Module::CoreList;
+use CPAN::Perl::Releases;
use version;
use LWP::UserAgent;
select $old_fh;
}
-my $has_cpan_perl_releases;
-BEGIN {
- local $@;
- if (eval { require CPAN::Perl::Releases; 1 }) {
- print "Will use CPAN::Perl::Releases\n";
- $has_cpan_perl_releases = 1;
- }
-}
-
my %opts;
getopts('ft:m:', \%opts);
sub perl_archive_for {
my $version = shift;
- my $path;
-
- if ($has_cpan_perl_releases) {
- my $tarballs = CPAN::Perl::Releases::perl_tarballs($version);
-
- if (defined $tarballs) {
- $path = $tarballs->{'tar.gz'};
- }
- } else {
- my $uri = "http://search.cpan.org/dist/perl-$version";
+ my $tarballs = CPAN::Perl::Releases::perl_tarballs($version);
+ my $path = $tarballs->{'tar.gz'};
+ die "Could not find the archive for perl $version" unless defined $path;
- local $_;
- fetch_uri($uri => \$_);
+ my ($file) = ($path =~ m{([^/]*)$});
- if (m{id/(([^/])/\2([^/])/\2\3[^/]*/perl-\Q$version\E\.tar\.(?:gz|bz2))}) {
- $path = $1;
- }
- }
-
- if (defined $path) {
- my ($file) = ($path =~ m{([^/]*)$});
- return "http://$cpan_mirror/authors/id/$path", $file;
- } else {
- die "Could not infer the archive for perl $version";
- }
+ return "http://$cpan_mirror/authors/id/$path", $file;
}
sub bandwidth {