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