This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
In corelist.pl, refactor to avoid repeating the final output formatting string.
[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},
f0f8ac00
RGS
25 $module =~ s{^IO_Compress_Base/lib/}{},
26 $module =~ s{^IO_Compress_Zlib/(?:lib/)?}{},
d51d469b 27 $module =~ s{^Devel/PPPort}{Devel},
4a656c5e 28 $module =~ s{^Encode/encoding}{encoding},
dc5f10bb 29 $module =~ s{^IPC/SysV/}{IPC/},
4a656c5e 30 $module =~ s{^List/Util/lib/Scalar}{Scalar},
dc5f10bb
RGS
31 $module =~ s{^MIME/Base64/QuotedPrint}{MIME/QuotedPrint},
32 $module =~ s{^(?:DynaLoader|Errno|Opcode)/}{},
4a656c5e
RGS
33 );
34 $module =~ s{/}{::}g;
35 $module =~ s/(\.pm|_pm\.PL)$//;
0fdd9e5c 36 $lines{$module} = $version;
59189dd7
MB
37}, 'lib', 'ext', 'vms/ext', 'symbian/ext');
38
0fdd9e5c 39-e 'configpm' and $lines{Config} = 'undef';
cc8432b2 40
59189dd7
MB
41if (open my $ucdv, "<", "lib/unicore/version") {
42 chomp (my $ucd = <$ucdv>);
0fdd9e5c 43 $lines{Unicode} = "'$ucd'";
59189dd7
MB
44 close $ucdv;
45 }
4a656c5e 46print " $] => {\n";
0fdd9e5c
NC
47foreach (sort keys %lines) {
48 printf "\t%-24s=> $lines{$_},\n", "'$_'";
49}
4a656c5e 50print " },\n";