diff options
author | Leon Brocard <acme@astray.com> | 2011-06-23 15:26:12 +0100 |
---|---|---|
committer | Leon Brocard <acme@astray.com> | 2011-06-23 15:26:12 +0100 |
commit | dd99222174249c21cd2ee296fab66bf7ab5680b5 (patch) | |
tree | da88f9afb01e491895ba8aa823b6492dcabafefa /Porting/core-cpan-diff | |
parent | 134b8cd8023b245ceceb96a0cb1a255bd3400f27 (diff) | |
download | perl-dd99222174249c21cd2ee296fab66bf7ab5680b5.tar.gz |
Extract the code the maps from an author/distribution to a
CPAN URL into its own subroutine: cpan_url_distribution()
in Porting/core-cpan-diff
Diffstat (limited to 'Porting/core-cpan-diff')
-rw-r--r-- | Porting/core-cpan-diff | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/Porting/core-cpan-diff b/Porting/core-cpan-diff index 592dd494ff..8cabf2ced7 100644 --- a/Porting/core-cpan-diff +++ b/Porting/core-cpan-diff @@ -187,6 +187,17 @@ sub cpan_url { return $mirror_url . $cpan_path; } +# construct a CPAN URL for a author/distribution string like: +# BINGOS/Archive-Extract-0.52.tar.gz + +sub cpan_url_distribution { + my ( $mirror_url, $distribution ) = @_; + $distribution =~ /^([A-Z])([A-Z])/ + or die "ERROR: invalid DISTRIBUTION name (not /^[A-Z]{2}/): $distribution\n"; + my $path = "modules/by-authors/id/$1/$1$2/$distribution"; + return cpan_url( $mirror_url, $path ); +} + # compare a list of modules against their CPAN equivalents sub do_compare { @@ -621,12 +632,7 @@ sub get_distribution { unless ( -f $download_file ) { # not cached - $dist =~ /^([A-Z])([A-Z])/ - or die -"ERROR: $module: invalid DISTRIBUTION name (not /^[A-Z]{2}/): $dist\n"; - - my $url = - cpan_url( $mirror_url, "modules/by-authors/id/$1/$1$2/$dist" ); + my $url = cpan_url_distribution( $mirror_url, $dist ); my_getstore( $url, $download_file ) or die "ERROR: Could not fetch '$url'\n"; } |