Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@fujiwara
Last active December 19, 2015 02:19
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save fujiwara/5882670 to your computer and use it in GitHub Desktop.
Save fujiwara/5882670 to your computer and use it in GitHub Desktop.
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
Copy link

  • 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