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 feaยญtures, perยญforยญmance enhanceยญments, bug fixยญes, and othยญer improveยญments. It seems like a good time to highยญlight some of my favorite changes over the past decade and a half, espeยญcialยญly for those with more datยญed knowlยญedge of Perl. You can always click on the headยญers below for the full releasยญesโ€™ perldelta pages.

Perl 5.10 (2007)

This was a big release, comยญing as it did over five years after the preยญviยญous major 5.8 release. Not that Perl develยญopยญers were idleโ€”but it wouldยญnโ€™t be until verยญsion 5.14 that the lanยญguage would adopt a steady yearยญly release cadence.

Due to the build-โ€‹up time, many core enhanceยญments were made but the most imporยญtant was arguably the feature pragยญma, enabling the addiยญtion of new synยญtax that would othยญerยญwise break Perlโ€™s backยญward comยญpatยญiยญbilยญiยญty. 5.10 also introยญduced the defined-โ€‹or operยญaยญtor (//), state variยญables that perยญsist their preยญviยญous valยญue, the say funcยญtion for autoยญmatยญiยญcalยญly appendยญing a newยญline on outยญput (so much saved typยญing), and a large colยญlecยญtion of improveยญments to regยญuยญlar expresยญsions. In addiยญtion, this release introยญduced smart matchยญing (~~), though verยญsion 5.18 would evenยญtuยญalยญly relยญeยญgate it to experยญiยญmenยญtal staยญtus.

Perl 5.12 (2010)

This release also saw many new feaยญtures added, but if I had to pick one marยญquee item it would be experยญiยญmenยญtal supยญport for plugยญgable keyยญwords, which enabled authors to extend the lanยญguage itself withยญout modยญiยญfyยญing the core. Previously one would either use plain funcยญtions, hacky source filยญters, or the depยญreยญcatยญed Devel::Declare modยญule to simยญuยญlate this funcยญtionยญalยญiยญty. CPAN authors would go on to creยญate all kinds of new synยญtax, someยญtimes proยญtoยญtypยญing feaยญtures that would evenยญtuยญalยญly make their way into core.

Perl 5.14 (2011)

5.14 had a big list of enhanceยญments, includยญing Unicode 6.0 supยญport and a gagยญgle of regยญuยญlar expresยญsion feaยญtures. My favorite of these was the /r switch for non-โ€‹destructive subยญstiยญtuยญtions.

But as the first yearยญly cadence release, the changes in polยญiยญcy took cenยญter stage. The Perl 5 Porters (p5p) explicยญitยญly comยญmitยญted to supยญportยญing the two most recent staยญble release series, proยญvidยญing secuยญriยญty patchยญes only for release series occurยญring in the past three years. They also defined an explicยญit comยญpatยญiยญbilยญiยญty and depยญreยญcaยญtion polยญiยญcy, with defยญiยญnยญiยญtions for feaยญtures that may be experยญiยญmenยญtal, depยญreยญcatยญed, disยญcourยญaged, and removed.

Perl 5.16 (2012)

Another year, anothยญer verยญsion bump. This time the core enhanceยญments were all over the map (although no enhanceยญments to the map function ๐Ÿ˜€ ).

May I highยญlight anothยญer docยญuยญmenยญtaยญtion change, though? The perlootut Object-โ€‹Oriented Programming in Perl Tutorial replaced the old perltoot, perltooc, perlboot, and perlbot pages, proยญvidยญing an introยญducยญtion to object-โ€‹oriented design conยญcepts before strongยญly recยญomยญmendยญing the use of one of the OO sysยญtems from CPAN. Mentioned are Moose, its alterยญnaยญtive Mouse, Class::Accessor, Object::Tiny, and Role::Tinyโ€‹โ€™s usage with the latยญter two. Later verยญsions of perlootut would recยญomยญmend Moo rather than Mouse.

Perl 5.18 (2013)

As menยญtioned earยญliยญer, Perl 5.18 renยญdered smartยญmatch experยญiยญmenยญtal, as well as lexยญiยญcal use of the $_ variยญable. With these came a new catยญeยญgoยญry of warnยญings for experยญiยญmenยญtal feaยญtures and a method for overยญridยญing such warnยญings feature-โ€‹by-โ€‹feature. Fitting in with the secuยญriยญty and safeยญty theme, hashยญes were overยญhauled to ranยญdomยญize key/โ€‹value order, increasยญing their resisยญtance to algoยญrithยญmic comยญplexยญiยญty attacks.

But it wasยญnโ€™t all fencยญing in bad behavยญior. Lexical subยญrouยญtines made their first (experยญiยญmenยญtal) appearยญance, and although I conยญfess I havenโ€™t had much call for them in my work, othยญers have come up with some interยญestยญing uses. Four years latยญer they became non-โ€‹experimental.

Perl 5.20 (2014)

Three new synยญtax feaยญtures arrived in 2014: experยญiยญmenยญtal subยญrouยญtine sigยญnaยญtures (of which Iโ€™ve writยญten more about here), key/โ€‹value hash slices and index/โ€‹value array slices, and experยญiยญmenยญtal postยญfix derefยญerยญencยญing. This last enables cleanยญer left-โ€‹to-โ€‹right synยญtax when derefยญerยญencยญing variables:

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

Postfix derefยญerยญencยญing became non-โ€‹experimental in Perl 5.24, and vigยญorยญous disยญcusยญsion conยญtinยญues on subยญrouยญtine sigยญnaยญturesโ€™ future.

Perl 5.22 (2015)

Speaking of subยญrouยญtine sigยญnaยญtures, their locaยญtion moved to between the subยญrouยญtine name (if any) and the attribute list (if any). Previously they appeared after attribยญutยญes. The lesยญson? Remain conยญscious of experยญiยญmenยญtal feaยญtures in your code, and be preยญpared to make changes when upgrading.

In addiยญtion to the enhanceยญments, secuยญriยญty updates, perยญforยญmance fixยญes, and depยญreยญcaยญtions, develยญopยญers removed the hisยญtorยญiยญcalยญly notable CGI modยญule. First added to core in 1997 in recogยญniยญtion of its critยญiยญcal role in enabling web develยญopยญment, itโ€™s been supยญplantยญed by betยญter alterยญnaยญtives on CPAN.

Perl 5.24 (2016)

Perl 5.20โ€‹โ€™s postยญfix derefยญerยญencยญing was no longer experยญiยญmenยญtal, and develยญopยญers removed both lexยญiยญcal $_ and autoderefยญerยญencยญing on calls to push, pop, shift, unshift, splice, keys, values, and each.

Perl 5.26 (2017)

The incorยญpoยญraยญtion of experยญiยญmenยญtal feaยญtures conยญtinยญued, with lexยญiยญcal subยญrouยญtines movยญing into full supยญport. I like the added readยญabilยญiยญty enhanceยญments, though: indentยญed here-โ€‹documents; the /xx regยญuยญlar expresยญsion modยญiยญfiยญer for tabs and spaces in charยญacยญter classยญes; and @{^CAPTURE}, %{^CAPTURE}, and %{^CAPTURE_ALL} for regยญexp matchยญes with a litยญtle more self-documentation.

Perl 5.28 (2018)

Experimental subยญrouยญtine sigยญnaยญture and attribute orderยญing flipped back to its Perl 5.20 sequence of attributes-โ€‹then-โ€‹signature. Bit of a rollerยญcoastยญer ride on this one. You could do worse than using someยญthing like Type::Params until this setยญtles and get a wide variยญety of type conยญstraints in the bargain.

Perl 5.30 (2019)

Pour one out for AWK and Fortran proยญgramยญmers migratยญing to Perl: the $[variยญable for setยญting the lowยญer bound of arrays could no longer be set to anyยญthing othยญer than zero. This had a long depยญreยญcaยญtion cycle startยญing in Perl 5.12.

Perl 5.32 (2020)

In 2020 Perlโ€™s develยญopยญment moved to GitHub. And once again, Iโ€™m going to highยญlight readยญabilยญiยญty enhanceยญments: the experยญiยญmenยญtal isa operยญaยญtor 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 comยญparยญiยญson operยญaยญtors, leadยญing to the more mathยญeยญmatยญiยญcalยญly conยญcise 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 introยญducยญtion of experยญiยญmenยญtal try/โ€‹catch excepยญtion hanยญdling synยญtax. If you need to supยญport earยญliยญer verยญsions of Perl back to 5.14, you can use Feature::Compat::Try. Earlier this year I interยญviewed the feaยญture and modยญuleโ€™s author, Paul โ€‹โ€œLeoNerdโ€ Evans, for Perl.com. This year also marked the debut of Perlโ€™s new govยญerยญnance modยญel with the appointยญment of a Core Team and a three-โ€‹member Steering Council.

What are some of your favorite Perl improveยญments over the years? Check out the perlhist docยญuยญment for a detailed chronolยญoยญgy and refreshยญer with the varยญiยญous perldelta pages and leave me a comยญment below.

3 thoughts on “Perl can do that now!

  1. @smxi @RL_Dane @benjaminhollon @sotolf Nobody outยญside of #sysadยญmins lookยญing for a betยญter #sed or #awk paid attenยญtion to #Perl 3. Late Perl 4 to earยญly #Perl5 was when the web took off and it became the go-โ€‹to for (mostยญly half-โ€‹assed) #CGI scripts, so much so that its mainยญtainยญers includยญed the monoยญlithยญic CGI modยญule from verยญsion 5.004 (5.4) to 5.20.If you havenโ€™t looked at the lanยญguage much since v5.10 Iโ€™d invite you to a blog I wrote about some of the highยญlights since then: https://phoenixtrap.com/2021/05/25/perl-can-do-that-now/
    awk
    cgi
    perl
    perl5
    sed
    sysadยญmins
    Perl can do that now!โ€”The Phoenix Trap

Comments are closed.

Mentions