The just-released brand-new Perl 5.40 brings core enhancements, security updates, and changes to the popular scripting language, building on its robust features from the previous 5.38 version.
This update introduces new functionalities, optimizes existing ones, and addresses significant security vulnerabilities. Here’s about that in more detail..
What’s New in Perl 5.40 Programming Language
One of the standout features in Perl 5.40 is introducing the __CLASS__
keyword. This new addition allows for more precise class name retrievals within class-based contexts like methods and field initializers. It provides a runtime-aware class reference, which is particularly useful during constructor executions where “$self” isn’t accessible.
Moreover, Perl programmers can now utilize the :reader
attribute for class field variables to automatically generate accessor methods, simplifying code and enhancing readability. The update also includes the allowance of spaces in the -M
command-line option, aligning it with the existing behavior of the -I
option.
A significant syntax refinement is seen with introducing the ^^
logical xor operator, completing Perl’s set of logical operators. Meanwhile, features like try/catch blocks and iterating over multiple values with for
have moved from experimental to stable, indicating maturity in their implementation and reliability.
On the security side, Perl 5.40 patches notable vulnerabilities, including CVE-2023-47038, which addresses a buffer overflow issue, and CVE-2023-47039, which resolves a binary hijacking risk on Windows systems.
Regarding incompatibility and deprecations, the update introduced changes that may affect existing scripts, including adjustments to the reset EXPR
function, which now triggers ‘set magic’ on scalars, potentially affecting old scripts where it had no effect.
Furthermore, Perl continues to phase out features and syntax that could lead to ambiguity or errors, such as resolving class barewords as file handles.
Perl 5.40 also sees updates to a wide range of modules, from “Archive::Tar” to “IO::Socket::IP,” alongside the inclusion of new modules like “Term::Table” and “Test2::Suite” in the Perl core, reducing dependencies for module testing on CPAN.
Lastly, the new release boasts performance tweaks, including optimized negation operations and better handling of generic TARGMY optimizations, which can significantly speed up execution times for specific operations.
Developers are encouraged to refer to the Perl documentation and community resources for a detailed review of all the changes and for further information. Here’s the announcement; you can see the key differences from the previous version, 5.38, in detail here.