NAME

perldelta - what is new for perl v5.37.10

DESCRIPTION

This document describes differences between the 5.37.9 release and the 5.37.10 release.

If you are upgrading from an earlier release such as 5.37.8, first read perl5379delta, which describes differences between 5.37.8 and 5.37.9.

Core Enhancements

Some gotos are now permitted in defer and finally blocks

Perl version 5.36.0 added defer blocks and permitted the finally keyword to also add similar behaviour to try/catch syntax. These did not permit any goto expression within the body, as it could have caused control flow to jump out of the block. Now, some goto expressions are allowed, if they have a constant target label, and that label is found within the block.

use feature 'defer';

defer {
  goto LABEL;
  print "This does not execute\n";
  LABEL: print "This does\n";
}

New regexp variable ${^LAST_SUCCESSFUL_PATTERN}

This allows access to the last succesful pattern that matched in the current scope. Many aspects of the regex engine refer to the "last successful pattern". The empty pattern reuses it, and all of the magic regex vars relate to it. This allows access to its pattern. The following code

if (m/foo/ || m/bar/) {
    s//PQR/;
}

can be rewritten as follows

if (m/foo/ || m/bar/) {
    s/${^LAST_SUCCESSFUL_PATTERN}/PQR/;
}

and it will do the exactly same thing.

Deprecation warnings now have specific subcategories

As of 5.37.10 all deprecation warnings will have their own specific deprecation category which can be disabled individually. You can see a list of all deprecated features in perldeprecation, and in warnings. The following list is from warnings:

+- deprecated ----+
|                 |
|                 +- deprecated::apostrophe_as_package_separator
|                 |
|                 +- deprecated::delimiter_will_be_paired
|                 |
|                 +- deprecated::dot_in_inc
|                 |
|                 +- deprecated::goto_construct
|                 |
|                 +- deprecated::smartmatch
|                 |
|                 +- deprecated::unicode_property_name
|                 |
|                 +- deprecated::version_downgrade

It is still possible to disable all deprecation warnings in a single statement with

no warnings 'deprecated';

but as of 5.37.10 it is possible to have a finer grained control. As has historically been the case these warnings are automatically enabled with

use warnings;

%{^HOOK} API introduced

For various reasons it can be difficult to create subroutine wrappers for some of perls keywords. Any keyword which has an undefined prototype simply cannot be wrapped with a subroutine, and some keywords which perl permits to be wrapped are in practice very tricky to wrap. For example require is tricky to wrap, it is possible but doing so changes the stack depth, and the standard methods of exporting assume that they will be exporting to a package at certain stack depth up the stack, and the wrapper will thus change where functions are exported to unless implemented with a great deal of care. This can be very awkward to deal with.

Accordingly we have introduced a new hash called %{^HOOK} which is intended to facilitate such cases. When a keyword supports any kind of special hook then the hook will live in this new hash. Hooks in this hash will be named after the function they are called by, followed by two underbars and then the phase they are executed in, currently either before or after the keyword is executed.

In this initial release we support two hooks require__before and require__after. These are provided to make it easier to perform tasks before and after a require statement.

See perlvar for more details.

Modules and Pragmata

Updated Modules and Pragmata

  • Benchmark has been upgraded from version 1.23 to 1.24.

  • Class::Struct has been upgraded from version 0.67 to 0.68.

  • Config::Perl::V has been upgraded from version 0.35 to 0.36.

  • Data::Dumper has been upgraded from version 2.187 to 2.188.

  • Digest::SHA has been upgraded from version 6.03 to 6.04.

  • Env has been upgraded from version 1.05 to 1.06.

  • feature has been upgraded from version 1.80 to 1.81.

  • File::Spec has been upgraded from version 3.88 to 3.89.

  • Net::Cmd has been upgraded from version 3.14 to 3.15.

  • Math::Complex has been upgraded from version 1.61 to 1.62.

  • Module::CoreList has been upgraded from version 5.20230220 to 5.20230320.

  • overload has been upgraded from version 1.36 to 1.37.

  • POSIX has been upgraded from version 2.11 to 2.12.

  • Storable has been upgraded from version 3.29 to 3.31.

  • Test::Simple has been upgraded from version 1.302192 to 1.302194.

  • threads has been upgraded from version 2.34 to 2.35.

  • threads::shared has been upgraded from version 1.65 to 1.67.

  • Time::HiRes has been upgraded from version 1.9772 to 1.9774.

  • warnings has been upgraded from version 1.62 to 1.63.

  • XS::APItest has been upgraded from version 1.30 to 1.32.

Documentation

Changes to Existing Documentation

We have attempted to update the documentation to reflect the changes listed in this document. If you find any we have missed, open an issue at https://github.com/Perl/perl5/issues/new/choose.

Additionally, the following selected changes have been made:

pod/perldebguts.pod

  • Updates to regex internals documentation.

pod/perldeprecation.pod

  • Added information about unscheduled deprecations and their categories.

  • Added category information for existing scheduled deprecations.

  • Added smartmatch and apostrophe as a package separator deprecation data.

pod/perlexperiment.pod

  • Smartmatch has been moved from experimental status to deprecated status. Unfortunately the experiment did not work out.

pod/perlexperiment.pod

  • Documented new require hooks.

pod/perlguts.pod

  • Documented new magic types PERL_MAGIC_destruct, PERL_MAGIC_hook and PERL_MAGIC_hookelem.

  • Documented several new or existing save stack macros: SAVERCPV(), SAVEGENERICSV(), SAVEFREEPV(), SAVEFREERCPV()

  • Documented new mortalization callback macros: MORTALSVFUNC_X(), MORTALDESTRUCTOR_SV()

pod/perlop.pod

  • Document the behavior of matching the empty pattern better and specify its relationship to the new ${^LAST_SUCCESSFUL_PATTERN} properly.

pod/perlvar.pod

  • Added information on the new %{^HOOK} interface, and the new require__before and require__after hooks which it exposes.

  • Correct information on the regex variables ${^PREMATCH}, ${^MATCH} and ${^POSTMATCH}, all of which were incorrectly documented due to an oversight. Specifically they only work properly after a regex operation that used the /p modifier to enable them.

  • Added information on the new regex variable ${^LAST_SUCCESSFUL_PATTERN}, which represents the pattern of the last successful regex match in scope.

Diagnostics

The following additions or changes have been made to diagnostic output, including warnings and fatal error messages. For the complete list of diagnostic messages, see perldiag.

New Diagnostics

New Errors

New Warnings

Changes to Existing Diagnostics

Testing

Tests were added and changed to reflect the other additions and changes in this release. Furthermore, these significant changes were made:

  • Added t/op/hook/ for testing %{^HOOK} related functionality. Specifically the t/op/hook/require.t for testing the new require hooks.

  • Added t/op/deprecation.t to test that our deprecation policies are being followed properly.

  • Fixed bugs in t/harness and t/TEST that meant that tests in t/test_pl and t/class were not being run during normal testing.

Platform-Specific Notes

Windows
  • POSIX::dup2 no longer creates broken sockets. [GH #20920]

  • Closing a busy pipe could cause Perl to hang. [GH #19963]

Internal Changes

  • Added SAVERCPV() and SAVEFREERCPV() for better support for working with RCPV (reference counted string/pointer value) structures which currently are used in opcodes to share filename and warning bit data in a memory efficient manner.

  • Added MORTALSVFUNC_SV() and MORTALDESTRUCTOR_SV() macros, which make it possible to create a destructor which is fired at the end of the current statement. This uses the PERL_MAGIC_destruct magic to use "free" magic to trigger an action when a variable is freed. The action can be specified as a C function or as a Perl code reference.

  • Added the %{^HOOK} api and related PERL_MAGIC_hook and PERL_MAGIC_hookelem for providing ways to hook selected perl functions which for one reason or another are problematic to wrap with a customized subroutine.

  • Added support for ${^HOOK}{require__before} which can be used to rewrite the filename that require will try to load, and also to block require from loading a specific module, even via fully qualified filename. The hook can also be used to perform "pre-require" and "post-require" actions.

  • Added support for ${^HOOK}{require__after} which can be used to track what modules have been required after the fact.

  • Regular expression opcodes (regops) now use a standardized structure layout that uses unions to expose data in different format. This means it should be much easier to extend or modify regops to use more memory. This has been used to make a number of regops track how many parens they contain.

Selected Bug Fixes

  • In the new experimental class feature, attributes are no longer a syntax error when using the unit class syntax. [GH #20888].

  • A number of bugs related to capture groups in quantified groups in regular expression have been fixed, especially in alternations. For example in a pattern like:

    "foobazfoobar" =~ /((foo)baz|foo(bar))+/

    the regex variable $2 will not be "foo" as it once was, it will be undef.

  • Bugs with regex backreference operators that are inside of a capture group have been fixed. For instance:

    "xa=xaaa" =~ /^(xa|=?\1a){2}\z/

    will now correctly not match. [GH #10073]

  • SSGROW() and SSCHECK() have been reworked to ensure that the requested space is actually allocated. SSCHECK() is now an alias for SSGROW().

Acknowledgements

Perl 5.37.10 represents approximately 4 weeks of development since Perl 5.37.9 and contains approximately 23,000 lines of changes across 360 files from 21 authors.

Excluding auto-generated files, documentation and release tools, there were approximately 6,000 lines of changes to 220 .pm, .t, .c and .h files.

Perl continues to flourish into its fourth decade thanks to a vibrant community of users and developers. The following people are known to have contributed the improvements that became Perl 5.37.10:

Arne Johannessen, Craig A. Berry, Dan Jacobson, David Mitchell, Elvin Aslanov, Graham Knop, James E Keenan, James Raspass, Jon Gentle, Karen Etheridge, Karl Williamson, Leon Timmermans, Lukas Mai, Paul Evans, Philippe Bruhat (BooK), Richard Leach, Steve Hay, Tomasz Konojacki, Tony Cook, Yves Orton, Zefram.

The list above is almost certainly incomplete as it is automatically generated from version control history. In particular, it does not include the names of the (very much appreciated) contributors who reported issues to the Perl bug tracker.

Many of the changes included in this version originated in the CPAN modules included in Perl's core. We're grateful to the entire CPAN community for helping Perl to flourish.

For a more complete list of all of Perl's historical contributors, please see the AUTHORS file in the Perl source distribution.

Reporting Bugs

If you find what you think is a bug, you might check the perl bug database at https://github.com/Perl/perl5/issues. There may also be information at http://www.perl.org/, the Perl Home Page.

If you believe you have an unreported bug, please open an issue at https://github.com/Perl/perl5/issues. Be sure to trim your bug down to a tiny but sufficient test case.

If the bug you are reporting has security implications which make it inappropriate to send to a public issue tracker, then see "SECURITY VULNERABILITY CONTACT INFORMATION" in perlsec for details of how to report the issue.

Give Thanks

If you wish to thank the Perl 5 Porters for the work we had done in Perl 5, you can do so by running the perlthanks program:

perlthanks

This will send an email to the Perl 5 Porters list with your show of thanks.

SEE ALSO

The Changes file for an explanation of how to view exhaustive details on what changed.

The INSTALL file for how to build Perl.

The README file for general stuff.

The Artistic and Copying files for copyright information.