perl: find vendor versions by support times
[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 eval {
23         use List::Util 'first';
24         use Time::Piece;
25         use Time::Seconds;
26         use feature 'signatures';
27         sub linkversion ($v) {
28                 return sprintf('%vd', $v);
29         }
30
31         my $now = Time::Piece->new;
32         my $coreeol = ($now - ONE_YEAR * 3)->strftime('%F');
33         my $vcore = first { $info->{$_}{release} ge $coreeol } sort keys %{$info};
34         say "<p>Core security support is provided for 3 years",
35                 ", so typical users should run at least $_."
36                 for linkversion($vcore);
37
38         my $vendoreol = ($now - ONE_YEAR * 5)->strftime('%F');
39         my $vdebian = first {
40                 $info->{$_}{release} ge $vendoreol && $info->{$_}{distro}{debian}
41         } sort keys %{$info};
42         say sprintf "Stable distributions such as Debian %s maintain %s+.",
43                 $info->{$_}{distro}{debian}, linkversion($_) for $vdebian;
44
45         my $nowcmp = $now->strftime('%F');
46         my $vdino = first { $info->{$_}{support} ge $nowcmp } sort keys %{$info};
47         say "Enterprise platforms retain versions up to $_."
48                 for linkversion($vdino);
49         return 1;
50 } or Alert('Missing version recommendations', $@);
51 say '</p>';
52
53 for my $vernum (reverse sort keys %{$info}) {
54         my $verrow = $info->{$vernum};
55         defined $verrow->{unstable} and next unless exists $get{v};
56
57         say '<div class="section">';
58         say sprintf '<h2>%vd <small>%s</small></h2>', $vernum, $verrow->{release};
59         say '<dl>';
60         for (@{ $verrow->{new} }) {
61                 my ($topic, $desc, $attr) = @{$_};
62                 if ($attr) {
63                         my $title;
64                         if (defined $attr->{experimental}) {
65                                 $title = 'experimental';
66                         }
67                         if ($attr->{dropped}) {
68                                 next unless exists $get{v};
69                                 $title = sprintf 'removed in %vd', $attr->{dropped};
70                         }
71                         elsif ($attr->{stable}) {
72                                 $title .= sprintf ' until %vd', $attr->{stable};
73                         }
74                         if ($attr->{experimental}) {
75                                 $title = sprintf '<span title="experimental::%s">%s</span>',
76                                         $attr->{experimental}, $title;
77                         }
78                         if ($attr->{feature}) {
79                                 my $prefix = sprintf '<span title="%s">feature</span>',
80                                         $attr->{feature};
81                                 $title = join ', ', $prefix, $title // ();
82                         }
83                         $desc .= sprintf ' <em class="ex">(%s)</em>', $title;
84                 }
85                 say sprintf '<dt>%s<dd>%s', $topic, $desc || '<br/>';
86         }
87         say sprintf '<dt>Unicode</dt><dd>v%s', $_ for $verrow->{unicode} || ();
88         say '</dl>';
89         say "</div>\n";
90 }
91