仕事で使うなら各モジュールのバージョンまでちゃんと管理しなきゃだけど(OrePANとか使う必要がある)、趣味でやるようなゆるい開発用に。
#!/usr/bin/env perl
use strict;
use warnings;
use Perl6::Say;
use Path::Class;
use Pod::Parser;
use List::MoreUtils qw/uniq/;
use Regexp::Assemble;
my @perllocals = do {
my $version = do {
my $info = `perl -v`;
($info =~ /\(v(5[\.\d]+)\)/)[0];
};
my $search;
for my $path (@INC) {
if ($path =~ /(.+?$version)/) {
$search = $1 and last;
}
}
map {chomp $_; $_} `find $search -name 'perllocal.pod'`;
};
my $search = do {
my $ra = Regexp::Assemble->new;
$ra->add('^Module');
$ra->add('[^:]:[^:]');
$ra->re
};
my $parser = Pod::Parser->new;
my @modules = (
uniq
sort
grep {
$_ && $_ !~ /$search/;
}
map {
$_->{'-ptree'}->[0] =~ /^(.+)\|/;
}
grep {
ref($_) eq 'Pod::InteriorSequence'
}
map {
@{$parser->parse_text(scalar file($_)->slurp)};
}
@perllocals
);
say $_ for @modules;