4 title => 'perl version cheat sheet',
7 perl version feature features comparison
8 sheet cheat overview summary
10 stylesheet => [qw'light dark red'],
11 data => ['perl.inc.pl'],
14 use experimental 'signatures';
16 <h1>Perl release summary</h1>
18 <p>The most significant features introduced for recent versions of the Perl
21 my $info = Data('perl');
23 use feature 'signatures';
25 return sprintf 'v%d%03d', unpack 'C*', $v;
27 sub linkversion ($v) {
28 return showlink(sprintf('%vd', $v), '#'.vname($v));
32 use List::Util 'first';
36 my $now = Time::Piece->new;
37 if (my $ts = $get{at}) {
38 $now = $now->strptime($ts, '%Y-%m-%d');
39 say "Compatibility details emulated for <em>$ts</em>.";
41 my $ts = $now->strftime('%F');
42 my @versions = sort grep { $info->{$_}{release} le $ts } keys %{$info};
44 # perlpolicy: «We "officially" support the two most recent stable release
45 # series. [...] we will attempt to fix critical issues»
46 $info->{ $versions[-2] }{versum} //= "active core support";
47 $info->{ $versions[-1] }{versum} //= "latest stable release";
49 # perlpolicy: «we will attempt to fix critical issues in the two most
50 # recent stable 5.x release series»
51 my $coreeol = ($now - ONE_YEAR * 3)->strftime('%F');
52 my $vcore = first { $info->{$_}{release} ge $coreeol } @versions;
53 print "<p>Core security support is provided for 3 years";
54 print ", so typical users should run at least ", linkversion($_)
57 $info->{$vcore}{versum} //= "official security patches";
59 # «We encourage vendors to ship the most recent supported release of Perl
60 # at the time of their code freeze»
61 # assume debian ships after 1 year, and expires after 5 years LTS
62 my $vendoreol = ($now - ONE_YEAR * 6)->strftime('%F');
64 $info->{$_}{release} ge $vendoreol && $info->{$_}{distro}{debian}
66 say sprintf "Stable distributions such as Debian %s maintain %s+.",
67 $info->{$_}{distro}{debian}, linkversion($_) for $vdebian // ();
68 $info->{$vdebian}{versum} //= "still maintained by common vendors";
70 # extended support given at random
71 my $nowcmp = $now->strftime('%F');
72 my $vdino = first { $info->{$_}{support} ge $nowcmp } @versions;
73 say "Enterprise platforms retain versions up to $_."
74 for map { linkversion($_) } $vdino // ();
76 } or Alert('Missing version recommendations', $@);
79 for my $vernum (reverse sort keys %{$info}) {
80 my $verrow = $info->{$vernum};
81 defined $verrow->{unstable} and next unless exists $get{v};
83 say sprintf '<div class="section" id="%s">', vname($vernum);
84 my $title = $verrow->{release} // '?';
85 $title .= ": $_" for $verrow->{versum} // ();
86 say sprintf '<h2>%vd <small>%s</small></h2>', $vernum, $title;
88 for (@{ $verrow->{new} }) {
89 my ($topic, $desc, $attr) = @{$_};
90 $desc .= featattrs($attr);
91 my $ref = defined $attr->{name} && sprintf ' id="%s"', $attr->{name};
92 say sprintf '<dt%s>%s<dd>%s', $ref, $topic, $desc || '<br/>';
94 if (my $mods = $verrow->{modules}) {
96 my ($name, $desc, $attr) = @{$_};
97 my $ref = lc $name =~ s/::/_/gr;
98 $desc .= featattrs($attr);
99 printf '<dt id="%s"><code>use %s</code>', $ref, $name;
103 say sprintf '<dt>Unicode</dt><dd>v%s', $_ for $verrow->{unicode} || ();
108 sub featattrs ($attr) {
110 ref $attr or $attr = {eg => $attr};
112 if (defined $attr->{experimental}) {
113 $title = 'experimental';
115 if (defined $attr->{dropped}) {
116 no warnings 'exiting';
117 next unless exists $get{v}; # skip containing feature
118 $title = sprintf 'removed in %vd', $_ for $attr->{dropped} || ();
120 elsif ($attr->{stable}) {
121 $title .= sprintf ' until %vd', $attr->{stable};
123 if ($attr->{experimental}) {
124 $title = sprintf '<span title="experimental::%s">%s</span>',
125 $attr->{experimental}, $title;
126 $attr->{name} //= $attr->{experimental};
128 if ($attr->{feature}) {
129 my $prefix = sprintf '<span title="%s">feature</span>',
131 $title = join ', ', $prefix, $title // ();
132 $attr->{name} //= $attr->{feature};
134 $title = $title ? sprintf ' <em class="ex">(%s)</em>', $title : '';
136 if (my $eg = $attr->{eg}) {
137 my $pre = Entity($eg);
138 $pre =~ s<\N{ZERO WIDTH SPACE}>{</code><wbr/><code>}g;
139 $pre = " <small>{<code>$pre</code>}</small>";
140 $title = $pre . $title;