This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Sub::Name is working again for some time now
[perl5.git] / Porting / corelist-perldelta.pl
CommitLineData
603f4ea0
DG
1#!perl
2use 5.010;
3use strict;
4use warnings;
5use lib 'Porting';
6use Maintainers qw/%Modules/;
7use Module::CoreList;
8
88e14305
DG
9my $deprecated;
10
11#--------------------------------------------------------------------------#
12
13sub added {
14 my ($mod, $old_v, $new_v) = @_;
15 say "=item C<$mod>\n";
16 say "Version $new_v has been added to the Perl core.\n";
17}
18
19sub updated {
20 my ($mod, $old_v, $new_v) = @_;
21 say "=item C<$mod>\n";
22 say "Upgraded from version $old_v to $new_v.\n";
23 if ( $deprecated->{$mod} ) {
24 say "NOTE: C<$mod> is deprecated and may be removed from a future version of Perl.\n";
25 }
26}
27
28sub removed {
29 my ($mod, $old_v, $new_v) = @_;
30 say "=item C<$mod>\n";
31 say "Removed from the Perl core. Prior version was $old_v.\n";
32}
33
34sub generate_section {
35 my ($title, $item_sub, @mods ) = @_;
36 return unless @mods;
37
38 say "=head2 $title\n";
39 say "=over 4\n";
40
41 for my $tuple ( sort { lc($a->[0]) cmp lc($b->[0]) } @mods ) {
42 my ($mod,$old_v,$new_v) = @$tuple;
43 $old_v //= q('undef');
44 $new_v //= q('undef');
45 $item_sub->($mod, $old_v, $new_v);
46 }
47
48 say "=back\n";
49}
50
51#--------------------------------------------------------------------------#
52
603f4ea0
DG
53my $corelist = \%Module::CoreList::version;
54my @versions = sort keys %$corelist;
55
56# by default, compare latest two version in CoreList;
57my ($old, $new) = @ARGV;
58$old ||= $versions[-2];
59$new ||= $versions[-1];
88e14305 60$deprecated = $Module::CoreList::deprecated{$new};
603f4ea0 61
88e14305
DG
62my (@new,@deprecated,@removed,@pragmas,@modules);
63
64# %Modules defines what is currently in core
65for my $k ( keys %Modules ) {
a56dbb5e 66 warn "Considering $k";
88e14305
DG
67 next unless exists $corelist->{$new}{$k};
68 my $old_ver = $corelist->{$old}{$k};
69 my $new_ver = $corelist->{$new}{$k};
70 # in core but not in last corelist
71 if ( ! exists $corelist->{$old}{$k} ) {
72 push @new, [$k, undef, $new_ver];
73 }
74 # otherwise just pragmas or modules
75 else {
76 my $old_ver = $corelist->{$old}{$k};
77 my $new_ver = $corelist->{$new}{$k};
78 next unless defined $old_ver && defined $new_ver && $old_ver ne $new_ver;
79 my $tuple = [ $k, $old_ver, $new_ver ];
80 if ( $k eq lc $k ) {
81 push @pragmas, $tuple;
82 }
83 else {
84 push @modules, $tuple;
85 }
86 }
603f4ea0
DG
87}
88
88e14305
DG
89# in old corelist, but not this one => removed
90# N.B. This is exhaustive -- not just what's in %Modules, so modules removed from
91# distributions will show up here, too. Some person will have to review to see what's
92# important. That's the best we can do without a historical Maintainers.pl
93for my $k ( keys %{ $corelist->{$old} } ) {
94 if ( ! exists $corelist->{$new}{$k} ) {
95 push @removed, [$k, $corelist->{$old}{$k}, undef];
96 }
97}
98
99generate_section("New Modules and Pragmata", \&added, @new);
100generate_section("Pragmata Changes", \&updated, @pragmas);
101generate_section("Updated Modules", \&updated, @modules);
102generate_section("Removed Modules and Pragmata", \&removed, @removed);
103