Created
March 14, 2013 12:55
-
-
Save tobyink/5161085 to your computer and use it in GitHub Desktop.
Reports the names of CPAN distributions installed on the current Perl.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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