Skip to content

Instantly share code, notes, and snippets.

@dolmen
Last active August 29, 2015 14:03
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 dolmen/ec5d797d3fc694746c4c to your computer and use it in GitHub Desktop.
Save dolmen/ec5d797d3fc694746c4c to your computer and use it in GitHub Desktop.
A filter for a list of Perl 5 modules, that will remove pure core modules such as 'integer'
#!perl
use 5.010;
use strict;
use warnings;
use Module::CoreList 2.99;
use Getopt::Long;
my $verbose; # --verbose
my $invert = 0; # -v, like grep
GetOptions(
'verbose' => \$verbose,
'v|invert-match' => \$invert,
);
# perl -MModule::CoreList -E 'say for sort keys $Module::CoreList::version{$]}' | corelist-filter --verbose
while (<STDIN>)
{
chomp(my $module = $_);
# FIXME
# This check is not enough and Module::CoreList doesn't have enough
# information about dual-life state of a module
# Another source of information: the ext/ directory of perl source,
# but it lists only distributions.
# http://perl5.git.perl.org/perl.git/tree/HEAD:/ext
# According to BinGOs, the only way is to check if the module is not
# in 02packages.details.txt
my $matches =
$Module::CoreList::version{$]}{$module}
&& ! exists $Module::CoreList::upstream{$module};
if ($matches xor $invert) {
print STDERR "skipping $_" if $verbose
} else {
print
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment