The programming language Perl 5.42 is now available.

After a year of development, a release of the new stable branch of the Perl programming language — 5.42 has been published. During the preparation of this release, about 280 thousand lines of code were changed (excluding documentation and automatically generated code — 93 thousand), with changes affecting 1500 files, and 64 developers participated in the development.

The 5.42 branch has been released in accordance with the approved fixed development schedule established twelve years ago, which provides for the release of new stable branches once a year and corrective releases every three months. The first corrective release of Perl 5.42.1 is scheduled to be released about a month later, which will fix the most significant bugs identified during the implementation of Perl 5.42.0. At the same time, support for the 5.38 branch has been discontinued, and updates may only be released in the future if critical security issues are identified. The development process of the experimental branch 5.43 will begin soon, based on which a stable release of Perl 5.44 will be formed in June 2026, unless a decision is made to switch to versioning 7.x.

Key changes:

  • Experimental list processing operators have been added — "any { BLOCK } @list" and "all { BLOCK } @list," which resemble the operator "grep { BLOCK } @list" but can only return true or false values. The "all" operator returns "true" when the condition is met for all elements of the list, while the "any" operator returns "true" when the condition is met for at least one element. The functionality of the operators is similar to functions from the List::Util module, but the built-in versions are faster and consume less memory. use v5.42; use feature 'keyword_all'; no warnings 'experimental::keyword_all'; my @numbers = … if ( all { $_ % 2 == 0 } @numbers ) { say "All the numbers are even"; }
  • For fields defined within a class, the ":writer" attribute has been implemented, used for automatically creating a method that writes the value of a variable to the field for the current instance of the class. class Point { field $x :reader :writer :param; field $y :reader :writer :param; } my $p = Point->new( x => 20, y => 40 ); $p->set_x(60);
  • Support for defining lexical methods has been added, which, similar to the definition of lexical subs ('lexical_subs'), allows for creating methods that are only accessible within the scope of the lexical block in which they were created. The expression 'my method_name' is used to create such methods.
  • The operator '&->' has been added, allowing subs that are in lexical scope to be called as if they were methods. Together with the ability to define lexical methods, the new operator implements functionality similar to private methods.
  • The assignment operator 'A ^^= B' has been added, performing the operation 'A = A XOR B'.
  • The pragma 'source::encoding' has been added, defining the encoding of the source code. For code in ASCII encoding, you can specify 'use source::encoding 'ascii'' (default), and for UTF-8, 'use source::encoding 'utf8'', with the latter expression being equivalent to 'use utf8'. The interpreter will throw an error if UTF-8 characters are found in code marked as ASCII, or if escape sequences '\x{}' are used in code marked as UTF-8. To disable encoding checks for a portion of the code, you can use the value 'use no source::encoding'. In practice, the added pragma can be useful for identifying cases where a developer forgot to specify 'use utf8' for code in UTF-8 encoding.
  • A function chdir() has been added to the namespace 'CORE::'. For example, this function can now be called as '&CORE::chdir($dir)' or 'my $ref = \&CORE::chdir; $ref->($dir)'.
  • The expression 'no feature "apostrophe_as_package_separator"' has been added to disable support for using the character '‘' as a separator for package names (for example, 'My'Module'Var' instead of 'My::Module::Var'). Initially, in Perl 5.42, it was planned to remove support for such separators, which had previously been marked as deprecated, but during discussions it was decided to keep this feature by default while providing an option to disable it.
  • The functionality of 'switch' and the operator '~~', which were previously marked as deprecated and were scheduled for removal, has been reinstated among the returned capabilities. Starting with Perl releases 5.36 and 5.42, 'switch' and '~~' are disabled by default when binding code to specific versions of the language (for instance, when using 'use v5.42'), but can be activated with the expressions 'use feature "switch"' and 'use feature "smartmatch"'.
  • Support for Unicode specification 16.0 has been added.

Source: opennet.ru

Buy reliable website hosting with DDoS protection, VPS VDS servers 🔥 Buy reliable website hosting with DDoS protection, VPS VDS servers | ProHoster