Skip to content

Instantly share code, notes, and snippets.

@kurain
Created May 4, 2010 14:05
Show Gist options
  • Save kurain/389443 to your computer and use it in GitHub Desktop.
Save kurain/389443 to your computer and use it in GitHub Desktop.
to filtering cpan package
#!/usr/bin/perl
use strict;
use warnings;
use UNIVERSAL::require;
my @installed;
my @not_installed;
while (<>) {
chomp;
next unless $_ =~ /^perl-/;
next if $_ =~ /Sub-Exporter/;
my @elms = split /-/, $_;
next if @elms < 4;
my @names = @elms[1..($#elms-2)];
my $package = join "::", @names;
printf STDERR "%s\n ", $_;
printf STDERR "%s ... ", $package;
my $res = `cpanv $package`;
if ( $res ) {
print STDERR "[OK installed] \n";
push @installed, $package;
} else {
print STDERR "[NOTEICE not installed] \n";
print STDERR $@;
printf "%s\n", $package;
push @not_installed, $package;
}
}
warn sprintf "%d package installed\n" , scalar @installed;
warn sprintf "%d package not installed\n" , scalar @not_installed;
#!/usr/bin/perl
use strict;
use warnings;
use UNIVERSAL::require;
my $module = $ARGV[0];
return unless $module;
$module->require;
if ( $module->VERSION ) {
printf "%s\n", $module->VERSION;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment