Created
September 22, 2011 14:56
-
-
Save arisawa/1234983 to your computer and use it in GitHub Desktop.
get distname to using module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use LWP::Simple; | |
use YAML; | |
use CPAN::DistnameInfo; | |
use Module::CoreList; | |
while (my $module = <>) { | |
chomp $module; | |
my $yaml = get("http://cpanmetadb.appspot.com/v1.0/package/$module"); | |
my $meta = YAML::Load($yaml); | |
my $info = CPAN::DistnameInfo->new($meta->{distfile}); | |
my $dist = $info->dist; | |
next if $dist eq 'perl'; # it is maybe core module in perl5 | |
$dist =~ s/-/::/g if $dist ne "libwww-perl"; # libwww-perl is correct | |
my $core_version = Module::CoreList->first_release($dist) || ""; | |
next if ($core_version && $core_version <= 5.008); # rewrite to your perl version | |
print $dist ? "$module\t$dist\t$core_version\n" : "$module\tNONE\n"; # NONE is not found in cpanmetadb | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grep '^use' -h -r lib | perl -pne 's/^use ([^ ;]+).*/$1/' | sort -u | grep -v MyApp > modules.txt | |
perl get_distname.pl modules.txt | |
# and more.. | |
perl get_distname.pl modules.txt | grep -wv NONE | awk '{print $2}' | sort -u | sed "s/.*/requires '&';/" >> Makefile.PL | |
# should modify module names | |
# perl get_distname.pl modules.txt | grep -w NONE | awk '{print $1}' | sort -u | sed "s/.*/requires '&';/" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment