This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add a tool to generate data for Module::CoreList
[perl5.git] / Porting / corelist.pl
... / ...
CommitLineData
1#!perl
2# Generates info for Module::CoreList from this perl tree
3# run this from the root of a clean perl tree
4
5use 5.9.0;
6use strict;
7use warnings;
8use File::Find;
9use ExtUtils::MM_Unix;
10
11my @lines;
12find(sub {
13 /(\.pm|_pm\.PL)$/ or return;
14 /PPPort_pm\.PL/ and return;
15 my $module = $File::Find::name;
16 $module =~ /\b(demo|t)\b/ and return; # demo or test modules
17 my $version = MM->parse_version($_) // 'undef';
18 $version =~ /\d/ and $version = "'$version'";
19 # some heuristics to figure out the module name from the file name
20 $module =~ s{^(lib|ext)/}{}
21 and $1 eq 'ext'
22 and ( $module =~ s{^(.*)/lib/\1\b}{$1},
23 $module =~ s{(\w+)/\1\b}{$1},
24 $module =~ s{^Encode/encoding}{encoding},
25 $module =~ s{^MIME/Base64/QuotedPrint}{MIME/QuotedPrint},
26 $module =~ s{^List/Util/lib/Scalar}{Scalar},
27 $module =~ s{^(?:DynaLoader|Errno)/}{},
28 );
29 $module =~ s{/}{::}g;
30 $module =~ s/(\.pm|_pm\.PL)$//;
31 push @lines, sprintf "\t%-24s=> $version,\n", "'$module'";
32}, 'lib', 'ext');
33print " $] => {\n";
34print sort @lines;
35print " },\n";