Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ExtUtils::Installedで現在インストールされているモジュールからcpanfileを作る
$ perl installed2cpanfile > cpanfile
$ cpanm --installdeps .
#!/usr/bin/env perl
use strict;
use warnings;
use ExtUtils::Installed;
my $i = ExtUtils::Installed->new;
for my $module (keys %$i) {
next if $module eq ":private:" || $module =~ /-/ || $module eq "Perl";
my $version = $i->{$module}->{version};
next if $version !~ /^[\d.]*$/;
print "requires '$module', '$version';\n";
}
@hirose31

This comment has been minimized.

Copy link

hirose31 commented Jun 28, 2013

  • NetAddr::IP とか version が 4.069 になる(頭にスペースが入ってる…)ので、
  • developer release のは 1.04_12 とかになるので、
    • $version !~ /^\s*[\d._]*$/ のがいいかも
  • Minillaとか v0.5.3 なので $version =~ s/^v//; した方がいいかも
  • MooX::Types::MooseLike とか Sub::Exporter::Progressive とか、$module にハイフンの MooX-Types-MooseLike が入るんで、if (! $version) だったら $module =~ s/-/::/g; eval "require $module"; $version = $module->VERSION しなとかもすねぇ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.