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