This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Gisle points out that it's ok to ignore the return value of newSVrv.
[perl5.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 5.9.0;
6 use strict;
7 use warnings;
8 use File::Find;
9 use ExtUtils::MM_Unix;
10
11 my @lines;
12 find(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');
33 print "    $] => {\n";
34 print sort @lines;
35 print "    },\n";