Skip to content

Instantly share code, notes, and snippets.

@tobyink
Created March 14, 2013 12:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tobyink/5161085 to your computer and use it in GitHub Desktop.
Save tobyink/5161085 to your computer and use it in GitHub Desktop.
Reports the names of CPAN distributions installed on the current Perl.
use v5.10;
use strict;
use warnings;
use aliased "Path::Tiny" => "Path";
use aliased "Path::Iterator::Rule";
use aliased "JSON";
my @dists;
my $rule = Rule->new->file->name(".packlist");
for my $inc (@INC)
{
my $auto = Path->new($inc)->child("auto");
my $iter = $rule->iter($auto);
while (my $f = $iter->())
{
my $file = Path->new($f);
my $dist = $file->relative($auto);
next unless $dist =~ s{.\.packlist$}{};
$dist =~ s{/}{-}g;
push @dists, $dist;
}
}
print JSON->new->pretty(1)->canonical(1)->encode({
distributions => [sort @dists],
perl_version => "$^V",
platform => "$^O",
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment