4609ee865eee1ef2ca1c135a6996d03eb4c9cbbb
[p5sagit/p5-mst-13.2.git] / Porting / corelist.pl
1 #!perl
2 # Generates info for Module::CoreList from this perl tree
3 # run this from the root of a clean perl tree
4
5 use strict;
6 use warnings;
7 use File::Find;
8 use ExtUtils::MM_Unix;
9
10 my @lines;
11 find(sub {
12     /(\.pm|_pm\.PL)$/ or return;
13     /PPPort\.pm$/ and return;
14     my $module = $File::Find::name;
15     $module =~ /\b(demo|t|private)\b/ and return; # demo or test modules
16     my $version = MM->parse_version($_);
17     defined $version or $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{^Compress/IO/Base/lib/}{},
25               $module =~ s{^Devel/PPPort}{Devel},
26               $module =~ s{^Encode/encoding}{encoding},
27               $module =~ s{^MIME/Base64/QuotedPrint}{MIME/QuotedPrint},
28               $module =~ s{^List/Util/lib/Scalar}{Scalar},
29               $module =~ s{^(?:DynaLoader|Errno)/}{},
30             );
31     $module =~ s{/}{::}g;
32     $module =~ s/(\.pm|_pm\.PL)$//;
33     push @lines, sprintf "\t%-24s=> $version,\n", "'$module'";
34 }, 'lib', 'ext');
35 print "    $] => {\n";
36 print sort @lines;
37 print "    },\n";