Perl 5.40 Programming Language Released, Here’s What’s New

Perl 5.40 programming language brings a new CLASS keyword, enhanced error handling with try/catch, :reader attributes for field variables, and more.

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.

Bobby Borisov

Bobby Borisov

Bobby, an editor-in-chief at Linuxiac, is a Linux professional with over 20 years of experience. With a strong focus on Linux and open-source software, he has worked as a Senior Linux System Administrator, Software Developer, and DevOps Engineer for small and large multinational companies.

Think You're an Ubuntu Expert? Let's Find Out!

Put your knowledge to the test in our lightning-fast Ubuntu quiz!
Ten questions to challenge yourself to see if you're a Linux legend or just a penguin in the making.

1 / 10

Ubuntu is an ancient African word that means:

2 / 10

Who is the Ubuntu's founder?

3 / 10

What year was the first official Ubuntu release?

4 / 10

What does the Ubuntu logo symbolize?

5 / 10

What package format does Ubuntu use for installing software?

6 / 10

When are Ubuntu's LTS versions released?

7 / 10

What is Unity?

8 / 10

What are Ubuntu versions named after?

9 / 10

What's Ubuntu Core?

10 / 10

Which Ubuntu version is Snap introduced?

The average score is 68%