perl: version descriptions after release dates
[sheet.git] / perl.plp
1 <(common.inc.plp)><:
2
3 Html({
4         title => 'perl version cheat sheet',
5         version => '1.4',
6         keywords => [qw'
7                 perl version feature features comparison
8                 sheet cheat overview summary
9         '],
10         stylesheet => [qw'light dark red'],
11         data => ['perl.inc.pl'],
12 });
13
14 :>
15 <h1>Perl release summary</h1>
16
17 <p>The most significant features introduced for recent versions of the Perl
18 scripting language.
19 <:
20 my $info = Data('perl');
21
22 use feature 'signatures';
23 sub vname ($v) {
24         return sprintf 'v%d%03d', unpack 'C*', $v;
25 }
26 sub linkversion ($v) {
27         return showlink(sprintf('%vd', $v), '#'.vname($v));
28 }
29
30 eval {
31         use List::Util 'first';
32         use Time::Piece;
33         use Time::Seconds;
34
35         my @versions = sort keys %{$info};
36         my $now = Time::Piece->new;
37         $now = $now->strptime($_, '%Y-%m-%d') for $get{at} // ();
38
39         # perlpolicy: «We "officially" support the two most recent stable release
40         # series. [...] we will attempt to fix critical issues»
41         $info->{ $versions[-2] }{versum} //= "active core support";
42         $info->{ $versions[-1] }{versum} //= "latest stable release";
43
44         # perlpolicy: «we will attempt to fix critical issues in the two most
45         # recent stable 5.x release series»
46         my $coreeol = ($now - ONE_YEAR * 3)->strftime('%F');
47         my $vcore = first { $info->{$_}{release} ge $coreeol } @versions;
48         print "<p>Core security support is provided for 3 years";
49         print ", so typical users should run at least ", linkversion($_)
50                 for $vcore // ();
51         say '.';
52         $info->{$vcore}{versum} //= "official security patches";
53
54         # «We encourage vendors to ship the most recent supported release of Perl
55         # at the time of their code freeze» with debian&ubuntu having 5 years LTS
56         my $vendoreol = ($now - ONE_YEAR * 5)->strftime('%F');
57         my $vdebian = first {
58                 $info->{$_}{release} ge $vendoreol && $info->{$_}{distro}{debian}
59         } @versions;
60         say sprintf "Stable distributions such as Debian %s maintain %s+.",
61                 $info->{$_}{distro}{debian}, linkversion($_) for $vdebian // ();
62         $info->{$vdebian}{versum} //= "still maintained by common vendors";
63
64         # extended support given at random
65         my $nowcmp = $now->strftime('%F');
66         my $vdino = first { $info->{$_}{support} ge $nowcmp } @versions;
67         say "Enterprise platforms retain versions up to $_."
68                 for map { linkversion($_) } $vdino // ();
69         return 1;
70 } or Alert('Missing version recommendations', $@);
71 say '</p>';
72
73 for my $vernum (reverse sort keys %{$info}) {
74         my $verrow = $info->{$vernum};
75         defined $verrow->{unstable} and next unless exists $get{v};
76
77         say sprintf '<div class="section" id="%s">', vname($vernum);
78         my $title = $verrow->{release} // '?';
79         $title .= ": $_" for $verrow->{versum} // ();
80         say sprintf '<h2>%vd <small>%s</small></h2>', $vernum, $title;
81         say '<dl>';
82         for (@{ $verrow->{new} }) {
83                 my ($topic, $desc, $attr) = @{$_};
84                 if ($attr) {
85                         my $title;
86                         if (defined $attr->{experimental}) {
87                                 $title = 'experimental';
88                         }
89                         if ($attr->{dropped}) {
90                                 next unless exists $get{v};
91                                 $title = sprintf 'removed in %vd', $attr->{dropped};
92                         }
93                         elsif ($attr->{stable}) {
94                                 $title .= sprintf ' until %vd', $attr->{stable};
95                         }
96                         if ($attr->{experimental}) {
97                                 $title = sprintf '<span title="experimental::%s">%s</span>',
98                                         $attr->{experimental}, $title;
99                         }
100                         if ($attr->{feature}) {
101                                 my $prefix = sprintf '<span title="%s">feature</span>',
102                                         $attr->{feature};
103                                 $title = join ', ', $prefix, $title // ();
104                         }
105                         $desc .= sprintf ' <em class="ex">(%s)</em>', $title;
106                 }
107                 say sprintf '<dt>%s<dd>%s', $topic, $desc || '<br/>';
108         }
109         say sprintf '<dt>Unicode</dt><dd>v%s', $_ for $verrow->{unicode} || ();
110         say '</dl>';
111         say "</div>\n";
112 }
113