Last active
August 29, 2015 14:03
-
-
Save dolmen/70298e8ed822989a18d8 to your computer and use it in GitHub Desktop.
List of core-only modules
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
#!perl | |
# List of core-only modules: modules that are bundled with perl, and not on CPAN | |
# Unfortunately this list includes modules that are distributed on CPAN but have | |
# been hidden from PAUSE indexing. | |
# Example: Locale::Codes::Country_Codes | |
use 5.010; | |
use strict; | |
use warnings; | |
use Module::CoreList; | |
use CPAN::Common::Index::LocalPackage; | |
use URI::cpan; | |
use Getopt::Long; | |
my $perl_version = $]; | |
my $verbose; | |
GetOptions( | |
'verbose' => \$verbose, | |
'current' => sub { $perl_version = $] }, | |
'last' => sub { $perl_version = (sort { $b <=> $a } keys %Module::CoreList::version)[0] }, | |
); | |
if (@ARGV) { | |
my $v = shift @ARGV; | |
die "invalid perl version: 5.x.y | 5.xxx | 5.xxxyyy expected\n" | |
unless $v =~ /^5\.(?:[0-9]{3}(?:[0-9]{3})?|[0-9]+\.[0-9]+)$/; | |
require version; | |
$v = version->parse($v); | |
$perl_version = $v->stringify; | |
if ($perl_version !~ /^5\.[0-9]{6}$/) { | |
$perl_version = sprintf('%1.6f', $v->numify) | |
} | |
} | |
say STDERR "perl $perl_version" if $verbose; | |
my $core_modules = $Module::CoreList::version{$perl_version}; | |
die "invalid perl version: $perl_version unknown to Module::CoreList\n" | |
unless defined $core_modules; | |
my $index = CPAN::Common::Index::LocalPackage->new({ | |
source => "$ENV{HOME}/.cpan/sources/modules/02packages.details.txt.gz", | |
}); | |
my @core_only; | |
PKG: foreach my $package (sort keys %$core_modules) { | |
my @results = $index->search_packages({ package => $package }); | |
foreach (@results) { | |
my $dist = URI->new($_->{uri})->dist_name; | |
#say "$package: $dist"; | |
next PKG if $dist ne 'perl' | |
} | |
push @core_only, $package; | |
} | |
say for @core_only |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment