Last week saw the release of Perl 5.34.0 (you can get it here), and with it comes a year’s worth of new features, performance enhancements, bug fixes, and other improvements. It seems like a good time to highlight some of my favorite changes over the past decade and a half, especially for those with more dated knowledge of Perl. You can always click on the headers below for the full releases’ perldelta pages.

Perl 5.10 (2007)

This was a big release, coming as it did over five years after the previous major 5.8 release. Not that Perl developers were idle—but it wouldn’t be until version 5.14 that the language would adopt a steady yearly release cadence.

Due to the build-​up time, many core enhancements were made but the most important was arguably the feature pragma, enabling the addition of new syntax that would otherwise break Perl’s backward compatibility. 5.10 also introduced the defined-​or operator (//), state variables that persist their previous value, the say function for automatically appending a newline on output (so much saved typing), and a large collection of improvements to regular expressions. In addition, this release introduced smart matching (~~), though version 5.18 would eventually relegate it to experimental status.

Perl 5.12 (2010)

This release also saw many new features added, but if I had to pick one marquee item it would be experimental support for pluggable keywords, which enabled authors to extend the language itself without modifying the core. Previously one would either use plain functions, hacky source filters, or the deprecated Devel::Declare module to simulate this functionality. CPAN authors would go on to create all kinds of new syntax, sometimes prototyping features that would eventually make their way into core.

Perl 5.14 (2011)

5.14 had a big list of enhancements, including Unicode 6.0 support and a gaggle of regular expression features. My favorite of these was the /r switch for non-​destructive substitutions.

But as the first yearly cadence release, the changes in policy took center stage. The Perl 5 Porters (p5p) explicitly committed to supporting the two most recent stable release series, providing security patches only for release series occurring in the past three years. They also defined an explicit compatibility and deprecation policy, with definitions for features that may be experimental, deprecated, discouraged, and removed.

Perl 5.16 (2012)

Another year, another version bump. This time the core enhancements were all over the map (although no enhancements to the map function 😀 ).

May I highlight another documentation change, though? The perlootut Object-​Oriented Programming in Perl Tutorial replaced the old perltoot, perltooc, perlboot, and perlbot pages, providing an introduction to object-​oriented design concepts before strongly recommending the use of one of the OO systems from CPAN. Mentioned are Moose, its alternative Mouse, Class::Accessor, Object::Tiny, and Role::Tinys usage with the latter two. Later versions of perlootut would recommend Moo rather than Mouse.

Perl 5.18 (2013)

As mentioned earlier, Perl 5.18 rendered smartmatch experimental, as well as lexical use of the $_ variable. With these came a new category of warnings for experimental features and a method for overriding such warnings feature-​by-​feature. Fitting in with the security and safety theme, hashes were overhauled to randomize key/​value order, increasing their resistance to algorithmic complexity attacks.

But it wasn’t all fencing in bad behavior. Lexical subroutines made their first (experimental) appearance, and although I confess I haven’t had much call for them in my work, others have come up with some interesting uses. Four years later they became non-​experimental.

Perl 5.20 (2014)

Three new syntax features arrived in 2014: experimental subroutine signatures (of which I’ve written more about here), key/​value hash slices and index/​value array slices, and experimental postfix dereferencing. This last enables cleaner left-​to-​right syntax when dereferencing variables:

  • @{ $array_ref } becomes $array_ref->@*
  • %{ $hash_ref } becomes $hash_ref->%*
  • Etc.

Postfix dereferencing became non-​experimental in Perl 5.24, and vigorous discussion continues on subroutine signatures’ future.

Perl 5.22 (2015)

Speaking of subroutine signatures, their location moved to between the subroutine name (if any) and the attribute list (if any). Previously they appeared after attributes. The lesson? Remain conscious of experimental features in your code, and be prepared to make changes when upgrading.

In addition to the enhancements, security updates, performance fixes, and deprecations, developers removed the historically notable CGI module. First added to core in 1997 in recognition of its critical role in enabling web development, it’s been supplanted by better alternatives on CPAN.

Perl 5.24 (2016)

Perl 5.20s postfix dereferencing was no longer experimental, and developers removed both lexical $_ and autodereferencing on calls to push, pop, shift, unshift, splice, keys, values, and each.

Perl 5.26 (2017)

The incorporation of experimental features continued, with lexical subroutines moving into full support. I like the added readability enhancements, though: indented here-​documents; the /xx regular expression modifier for tabs and spaces in character classes; and @{^CAPTURE}, %{^CAPTURE}, and %{^CAPTURE_ALL} for regexp matches with a little more self-documentation.

Perl 5.28 (2018)

Experimental subroutine signature and attribute ordering flipped back to its Perl 5.20 sequence of attributes-​then-​signature. Bit of a rollercoaster ride on this one. You could do worse than using something like Type::Params until this settles and get a wide variety of type constraints in the bargain.

Perl 5.30 (2019)

Pour one out for AWK and Fortran programmers migrating to Perl: the $[variable for setting the lower bound of arrays could no longer be set to anything other than zero. This had a long deprecation cycle starting in Perl 5.12.

Perl 5.32 (2020)

In 2020 Perl’s development moved to GitHub. And once again, I’m going to highlight readability enhancements: the experimental isa operator could be used to say:

if ( $obj isa Some::Class ) { ... }

instead of

use Scalar::Util 'blessed';
if ( blessed($obj) and $obj->isa('Some::Class') { ... }

You could also chain comparison operators, leading to the more mathematically concise if ( $x < $y <= $z ) {...} rather than if ( $x < $y and $y <= $z ) {...}.

Perl 5.34 (2021)

Finally, we come to last week’s release and its introduction of experimental try/​catch exception handling syntax. If you need to support earlier versions of Perl back to 5.14, you can use Feature::Compat::Try. Earlier this year I interviewed the feature and module’s author, Paul LeoNerd” Evans, for This year also marked the debut of Perl’s new governance model with the appointment of a Core Team and a three-​member Steering Council.

What are some of your favorite Perl improvements over the years? Check out the perlhist document for a detailed chronology and refresher with the various perldelta pages and leave me a comment below.

3 thoughts on “Perl can do that now!

  1. @smxi @RL_Dane @benjaminhollon @sotolf Nobody outside of #sysadmins looking for a better #sed or #awk paid attention to #Perl 3. Late Perl 4 to early #Perl5 was when the web took off and it became the go-​to for (mostly half-​assed) #CGI scripts, so much so that its maintainers included the monolithic CGI module from version 5.004 (5.4) to 5.20.If you haven’t looked at the language much since v5.10 I’d invite you to a blog I wrote about some of the highlights since then:
    Perl can do that now!—The Phoenix Trap

Comments are closed.