This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Break out the logic that maps file names to modules into files_to_modules().
[perl5.git] / Porting / corelist.pl
CommitLineData
4a656c5e
RGS
1#!perl
2# Generates info for Module::CoreList from this perl tree
3# run this from the root of a clean perl tree
4
4a656c5e
RGS
5use strict;
6use warnings;
7use File::Find;
8use ExtUtils::MM_Unix;
9
59189dd7 10my %lines;
4a656c5e
RGS
11find(sub {
12 /(\.pm|_pm\.PL)$/ or return;
d51d469b 13 /PPPort\.pm$/ and return;
4a656c5e 14 my $module = $File::Find::name;
d51d469b
RGS
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';
4a656c5e
RGS
18 $version =~ /\d/ and $version = "'$version'";
19 # some heuristics to figure out the module name from the file name
4a626d91
RGS
20 $module =~ s{^(lib|(win32/|vms/|symbian/)?ext)/}{}
21 and $1 ne 'lib'
4a656c5e
RGS
22 and ( $module =~ s{^(.*)/lib/\1\b}{$1},
23 $module =~ s{(\w+)/\1\b}{$1},
dc5f10bb 24 $module =~ s{^B/O}{O},
da09dfe3 25 $module =~ s{^Devel-PPPort}{Devel},
4a656c5e 26 $module =~ s{^Encode/encoding}{encoding},
da09dfe3
NC
27 $module =~ s{^IPC-SysV/}{IPC/},
28 $module =~ s{^MIME-Base64/QuotedPrint}{MIME/QuotedPrint},
dc5f10bb 29 $module =~ s{^(?:DynaLoader|Errno|Opcode)/}{},
4a656c5e
RGS
30 );
31 $module =~ s{/}{::}g;
da09dfe3
NC
32 $module =~ s{-}{::}g;
33 $module =~ s{^.*::lib::}{};
4a656c5e 34 $module =~ s/(\.pm|_pm\.PL)$//;
0fdd9e5c 35 $lines{$module} = $version;
59189dd7
MB
36}, 'lib', 'ext', 'vms/ext', 'symbian/ext');
37
0fdd9e5c 38-e 'configpm' and $lines{Config} = 'undef';
cc8432b2 39
59189dd7
MB
40if (open my $ucdv, "<", "lib/unicore/version") {
41 chomp (my $ucd = <$ucdv>);
0fdd9e5c 42 $lines{Unicode} = "'$ucd'";
59189dd7
MB
43 close $ucdv;
44 }
4a656c5e 45print " $] => {\n";
0fdd9e5c
NC
46foreach (sort keys %lines) {
47 printf "\t%-24s=> $lines{$_},\n", "'$_'";
48}
4a656c5e 49print " },\n";