|Perl 5.36 Released - What's New?|
|Written by Nikos Vaggalis|
|Monday, 13 June 2022|
Perl 5.36 was recently released and comes with many great features. It's a prelude to Perl 7 but might prove more than that since 7's future is still uncertain.
First of all borrowing from Perl's 7 philosophy, 5.36 comes with modern and sensible defaults. That is, use 5.36; loads pragmas and features already being advised for years to programmers writing in Perl, like turning strict and warnings on, use 5.010 or importing Modern::Perl, which are now going to be set by default when you start writing a new program under this version.
According to Ricardo Signes, that directive in place does the following:
However that's not the whole story as use 5.36 imports more defaults. More details come from the Perl Steering Committee which says that that one line is equivalent to:
That is what is meant in part by "turns on all the same new features as v5.34".
Such a feature introduced in v5.34 finds its way into v5.36 too but becomes more evolved.That is, the new way of handling exceptions under the try/catch construct which brings Perl up to par with many of the other programming language which use it as their default mechanism. This means that now instead of the classic way of checking for exceptions:
we switch to:
There were third party try/catch modules on CPAN, like Syntax::Keyword::Try, which extended Perl with that feature, but now it seems that it's finding its way into the core. However, the feature is still experimental and has to be enabled by issuing:
In 5.36 additionally it gets a finally block too:
As already said in the introduction, the important feature of subroutine signatures turns from experimental to default after many iterations. It is now considered a stable language feature and no longer prints a warning.
Newly and experimentally introduced is the builtin pragma, which imports several utility functions which were always present in the interpreter and now can be called at any time by their fully-qualified names.
These builtin imports extend functionality. For instance:
which as Perl doesn't have strict typing of Booleans, these values will be known to have been created as Booleans, for example is_bool will tell you whether a value was known to have been created as a Boolean.
Under the same perspective:
returns a Boolean identifying whether the argument value was originally created as a number or a string.
These two functions are intended to be used by data serialisation modules such as JSON encoders or similar situations, where language interoperability concerns require making a distinction between values that are fundamentally stringlike versus numberlike in nature.
The convenient functionality of iterating over multiple values at a time comes in experimentally. You can now iterate over multiple values at a time by specifying a list of lexicals within parentheses. For example,
Prior to Perl v5.36, attempting to specify a list after for my was a syntax error.
As with try/catch, another feature found in other languages like Go, finds its way in. That is, blocks prefixed by the defer modifier provide a section of code which runs at a later time during scope exit.
A new command-line flag, -g, is available as a simpler alias for -0777.In essence it undefines the input record separator ($/) and thus enables the slurp mode - that is, it causes Perl to read whole files at once instead of line by line.
Of course, as Perl is always at the forefront of Unicode support, v5.36 comes with Unicode 14.0.
As is always the case, each release also features deprecations, performance enhancements and updates to modules and pragmata. So the default modules that Perl is using have also been updated to newer versions. As such Archive::Tar has been upgraded from version 2.38 to 2.40, Data::Dumper from version 2.179 to 2.184, Scalar::Util from version 1.55 to 1.62, etc.
It is important to note that the versions of the modules don't correlate to Perl's version. For example, the latest version 2.40 of Archive::Tar was released on July 27, 2021 while Perl 5.36 arrived on May 28, 2022; it's just 5.36 has been upgraded to incorporate the modules' latest versions, whenever they were released.
For more details and all the new introductions as well changes, check the perl delta of the version.
Also, 5.36 is one of the last versions incorporating Perl's default OO mechanism. Future versions will likely incorporate the post-modern Corina OO system, spearheaded by Ovid. According to him:
If you’re waiting for the Corinna OOP project to land in the Perl core, you’ll have to wait. Paul Evans will start working on the implementation after Perl version 5.36 is released. However, it’s a lot of work and it’s not clear that if it will be ready by 5.38 and even then, it will be experimental. You’ve a couple of years to wait.
With that said, you think that it's all over? It is not! With the ink on the release still not dry, the first development release of the v5.37 series became available! Following its perl delta, we find Perl 5.37.0 represents approximately 2 hours of development since Perl 5.36.0 and contains approximately 3,600 lines of changes across 37 files from 1 author. Excluding auto-generated files, documentation and release tools, there were approximately 61 lines of changes to 6 .pm, .t, .c and .h files.
So yes,you haven't missed out on anything important by not following tracks to v5.37. That won't be the case though when v5.38 arrives. Till then enjoy 5.36.
or email your comment to: email@example.com
|Last Updated ( Monday, 13 June 2022 )|