Perl can do that now!
Tags: perl, languages
Published: 2021-05-25 15:17:36

---
title: Perl can do that now!
published: true
date: 2021-05-25 14:00:00 UTC
tags: Perl,languages
canonical_url: https://phoenixtrap.com/2021/05/25/perl-can-do-that-now/?utm_source=rss&utm_medium=rss&utm_campaign=perl-can-do-that-now
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ot3rhwj14xwi2tfycsi9.jpeg
---

Last week saw the [release](https://metacpan.org/release/XSAWYERX/perl-5.34.0) of Perl 5.34.0 (you can [get it here](https://www.perl.org/get.html)), and with it comes a year’s worth of [new features](https://perldoc.pl/5.34.0/perldelta#Core-Enhancements), [performance enhancements](https://perldoc.pl/5.34.0/perldelta#Performance-Enhancements), [bug fixes](https://perldoc.pl/5.34.0/perldelta#Selected-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](https://perldoc.pl/perl5100delta) (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](https://perldoc.pl/perl5100delta#Core-Enhancements) were made but the most important was arguably [the `feature` pragma](https://perldoc.pl/perl5100delta#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](https://perldoc.pl/perl5100delta#Defined-or-operator) (`//`), [`state` variables](https://perldoc.pl/perl5100delta#state()-variables) that persist their previous value, the [`say` function](https://perldoc.pl/perl5100delta#say()) for automatically appending a newline on output (so much saved typing), and a large collection of [improvements to regular expressions](https://perldoc.pl/perl5100delta#Regular-expressions). In addition, this release introduced [smart matching](https://perldoc.pl/perl5100delta#Switch-and-Smart-Match-operator) (`~~`), though version 5.18 would eventually [relegate it to experimental status](https://perldoc.pl/perl5180delta#The-smartmatch-family-of-features-are-now-experimental).

## [Perl 5.12](https://perldoc.pl/perl5120delta) (2010)

This release also saw many [new features](https://perldoc.pl/perl5120delta#Core-Enhancements) added, but if I had to pick one marquee item it would be experimental support for [pluggable keywords](https://perldoc.pl/perl5120delta#Pluggable-keywords), which [enabled authors](https://metacpan.org/search?q=Keyword) to **extend the language itself** without modifying the core. Previously one would either use plain functions, hacky [source filters](https://perldoc.perl.org/perlfilter), or the deprecated [Devel::Declare](https://metacpan.org/pod/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](https://perldoc.pl/perl5140delta) (2011)

5.14 had a big list of [enhancements](https://perldoc.pl/perl5140delta#Core-Enhancements), including [Unicode 6.0 support](https://perldoc.pl/perl5140delta#Unicode) and a gaggle of [regular expression features](https://perldoc.pl/perl5140delta#Unicode). My favorite of these was the `/r` switch for [non-destructive substitutions](https://perldoc.pl/perl5140delta#Non-destructive-substitution).

But as the **first yearly cadence release** , the [changes in policy](https://perldoc.pl/5.14.0/perlpolicy) took center stage. The Perl 5 Porters (p5p) [explicitly committed](https://perldoc.pl/5.14.0/perlpolicy#MAINTENANCE-AND-SUPPORT) 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](https://perldoc.pl/5.14.0/perlpolicy#BACKWARD-COMPATIBILITY-AND-DEPRECATION), with definitions for features that may be [experimental](https://perldoc.pl/5.14.0/perlpolicy#experimental), [deprecated](https://perldoc.pl/5.14.0/perlpolicy#deprecated), [discouraged](https://perldoc.pl/5.14.0/perlpolicy#discouraged), and [removed](https://perldoc.pl/5.14.0/perlpolicy#removed).

## [Perl 5.16](https://perldoc.pl/perl5160delta) (2012)

Another year, another version bump. This time the [core enhancements](https://perldoc.pl/perl5160delta#Core-Enhancements) were all over the map (although no enhancements to the [`map`](https://perldoc.pl/5.16.0/functions/map) function 😉).

May I highlight another documentation change, though? The [`perlootut`](https://perldoc.pl/5.16.0/perlootut) **Object-Oriented Programming in Perl Tutorial** [replaced](https://perldoc.pl/perl5160delta#Old-OO-Documentation) the old [`perltoot`](https://perldoc.pl/5.14.4/perltoot), [`perltooc`](https://perldoc.pl/5.14.4/perltooc), [`perlboot`](https://perldoc.pl/5.14.4/perlboot), and [`perlbot`](https://perldoc.pl/5.14.4/perlbot) pages, providing an introduction to object-oriented design concepts before [strongly recommending](https://perldoc.pl/5.16.0/perlootut#PERL-OO-SYSTEMS) the use of one of the OO systems from CPAN. Mentioned are [Moose](https://metacpan.org/pod/Moose), its alternative [Mouse](https://metacpan.org/pod/Mouse), [Class::Accessor](https://metacpan.org/pod/Class::Accessor), [Object::Tiny](https://metacpan.org/pod/Object::Tiny), and [Role::Tiny](https://metacpan.org/pod/Role::Tiny)’s usage with the latter two. Later versions of `perlootut` would recommend [Moo](https://perldoc.pl/perlootut#Moo) rather than Mouse.

## [Perl 5.18](https://perldoc.pl/perl5180delta) (2013)

As [mentioned earlier](#perl510), Perl 5.18 rendered smartmatch [experimental](https://perldoc.pl/perl5180delta#The-smartmatch-family-of-features-are-now-experimental), as well as [lexical use](https://perldoc.pl/perl5180delta#Lexical-%24_-is-now-experimental) of the `$_` variable. With these came a new [category of warnings](https://perldoc.pl/5.18.0/perllexwarn#Category-Hierarchy) for experimental features and a [method for overriding such warnings](https://perldoc.pl/perl5180delta#New-mechanism-for-experimental-features) feature-by-feature. Fitting in with the [security](https://perldoc.pl/perl5180delta#Security) and safety theme, [hashes were overhauled](https://perldoc.pl/perl5180delta#Hash-overhaul) to [randomize](https://perldoc.pl/perl5180delta#Hash-randomization) key/value order, increasing their resistance to algorithmic complexity attacks.

**But it wasn’t all fencing in bad behavior.** [Lexical subroutines](https://perldoc.pl/5.18.0/perlsub#Lexical-Subroutines) made [their first (experimental) appearance](https://perldoc.pl/perl5180delta#Lexical-subroutines), and although I confess I haven’t had much call for them in my work, others have [come up with some interesting uses](https://rjbs.manxome.org/rubric/entry/2016). Four years later they [became non-experimental](https://perldoc.pl/perl5260delta#Lexical-subroutines-are-no-longer-experimental).

## [Perl 5.20](https://perldoc.pl/perl5200delta) (2014)

Three new syntax features arrived in 2014: experimental [subroutine signatures](https://perldoc.pl/perl5200delta#Experimental-Subroutine-signatures) (of which [I’ve written more about here](https://phoenixtrap.com/2021/01/27/better-perl-with-subroutine-signatures-and-type-validation/)), [key/value hash slices and index/value array slices](https://perldoc.pl/perl5200delta#New-slice-syntax), and experimental [postfix dereferencing](https://perldoc.pl/perl5200delta#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](https://perldoc.pl/perl5240delta#Postfix-dereferencing-is-no-longer-experimental), and [vigorous discussion continues](https://github.com/Perl/perl5/issues/18537) on subroutine signatures’ future.

## [Perl 5.22](https://perldoc.pl/perl5220delta) (2015)

Speaking of subroutine signatures, [their location moved](https://perldoc.pl/perl5220delta#Subroutine-signatures-moved-before-attributes) 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](https://perldoc.pl/perl5220delta#Core-Enhancements), [security updates](https://perldoc.pl/perl5220delta#Security), [performance fixes](https://perldoc.pl/perl5220delta#Performance-Enhancements), and [deprecations](https://perldoc.pl/perl5220delta#Deprecations), developers [**removed the historically notable CGI module**](https://perldoc.pl/perl5220delta#Deprecations). First [added to core](https://perldoc.pl/perl5004delta#Module-information-summary) in 1997 in recognition of its critical role in enabling web development, it’s been supplanted by [better alternatives](https://metacpan.org/pod/CGI::Alternatives) on CPAN.

## [Perl 5.24](https://perldoc.pl/perl5240delta) (2016)

[Perl 5.20](#perl520)’s postfix dereferencing was [no longer experimental](https://perldoc.pl/perl5240delta#Postfix-dereferencing-is-no-longer-experimental), and developers removed both [lexical `$_`](https://perldoc.pl/perl5240delta#Lexical-%24_-has-been-removed) and [autodereferencing](https://perldoc.pl/perl5240delta#The-autoderef-feature-has-been-removed) on calls to [`push`](https://perldoc.pl/functions/push), [`pop`](https://perldoc.pl/functions/pop), [`shift`](https://perldoc.pl/functions/shift), [`unshift`](https://perldoc.pl/functions/unshift), [`splice`](https://perldoc.pl/functions/splice), [`keys`](https://perldoc.pl/functions/keys), [`values`](https://perldoc.pl/functions/values), and [`each`](https://perldoc.pl/functions/each).

## [Perl 5.26](https://perldoc.pl/perl5260delta) (2017)

The incorporation of experimental features continued, with [lexical subroutines moving into full support](https://perldoc.pl/perl5260delta#Lexical-subroutines-are-no-longer-experimental). I like the **added readability enhancements** , though: [indented here-documents](https://perldoc.pl/perl5260delta#Indented-Here-documents); the [`/xx` regular expression modifier](https://perldoc.pl/perl5260delta#New-regular-expression-modifier-/xx) for tabs and spaces in character classes; and [`@{^CAPTURE}`, `%{^CAPTURE}`, and `%{^CAPTURE_ALL}`](https://perldoc.pl/perl5260delta#@%7B%5ECAPTURE%7D,-%25%7B%5ECAPTURE%7D,-and-%25%7B%5ECAPTURE_ALL%7D) for regexp matches with a little more self-documentation.

## [Perl 5.28](https://perldoc.pl/perl5280delta) (2018)

Experimental subroutine signature and attribute ordering [flipped back](https://perldoc.pl/perl5280delta#Subroutine-attribute-and-signature-order) 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](https://metacpan.org/pod/Type::Params) until this settles and get a wide variety of type constraints in the bargain.

## [Perl 5.30](https://perldoc.pl/perl5300delta) (2019)

Pour one out for AWK and Fortran programmers migrating to Perl: [the `$[` variable](https://perldoc.pl/variables/%24%5B) for setting the lower bound of arrays could [no longer be set to anything other than zero](https://perldoc.pl/perl5300delta#Assigning-non-zero-to-%24%5B-is-fatal). This had a long deprecation cycle [starting in Perl 5.12](#perl512).

## [Perl 5.32](https://perldoc.pl/perl5320delta) (2020)

In 2020 Perl’s development [moved to GitHub](https://perldoc.pl/perl5320delta#Perl-is-now-developed-on-GitHub). And once again, I’m going to **highlight readability enhancements** : the experimental [`isa` operator](https://perldoc.pl/perlop#Class-Instance-Operator) could be used to say:

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

instead of

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

You could also [chain comparison operators](https://perldoc.pl/perl5320delta#Chained-comparisons-capability), leading to the more mathematically concise `if ( $x < $y <= $z ) {...}` rather than `if ( $x < $y and $y <= $z ) {...}`.

## [Perl 5.34](https://perldoc.pl/5.34.0/perldelta) (2021)

Finally, we come to **last week’s release** and its introduction of [experimental `try`/`catch` exception handling syntax](https://perldoc.pl/5.34.0/perldelta#Experimental-Try/Catch-Syntax). If you need to support earlier versions of Perl back to 5.14, you can use [Feature::Compat::Try](https://metacpan.org/pod/Feature::Compat::Try). Earlier this year I [interviewed the feature and module’s author, Paul “LeoNerd” Evans](https://www.perl.com/article/interview-trying-to-catch-paul-leonerd-evans/), for Perl.com. This year also marked the debut of Perl’s new [governance model](https://perldoc.pl/perlgov) with the appointment of a [Core Team](https://perldoc.pl/perlgov#The-Core-Team) and a three-member [Steering Council](https://perldoc.pl/perlgov#The-Steering-Council).

**What are some of your favorite Perl improvements over the years?** Check out the [`perlhist` document](https://perldoc.pl/perlhist) for a detailed chronology and refresher with the various [`perldelta` pages](https://perldoc.pl/perl#History) and leave me a comment below.