Skip to content

Instantly share code, notes, and snippets.

@Cside
Created February 17, 2011 00:40
Show Gist options
  • Save Cside/830672 to your computer and use it in GitHub Desktop.
Save Cside/830672 to your computer and use it in GitHub Desktop.
インストールしてるモジュール一覧をperllocal.podから
#!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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment