=encoding utf8 =head1 NAME perldelta - what is new for perl v5.37.10 =head1 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 L, which describes differences between 5.37.8 and 5.37.9. =head1 Core Enhancements =head2 Some Cs are now permitted in C and C blocks Perl version 5.36.0 added C blocks and permitted the C keyword to also add similar behaviour to C/C syntax. These did not permit any C expression within the body, as it could have caused control flow to jump out of the block. Now, some C 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"; } =head2 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. =head2 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 L, and in L. The following list is from L: +- 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; =head2 %{^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 C 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 C<%{^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 C and C. These are provided to make it easier to perform tasks before and after a require statement. See L for more details. =head1 Modules and Pragmata =head2 Updated Modules and Pragmata =over 4 =item * L has been upgraded from version 1.23 to 1.24. =item * L has been upgraded from version 0.67 to 0.68. =item * L has been upgraded from version 0.35 to 0.36. =item * L has been upgraded from version 2.187 to 2.188. =item * L has been upgraded from version 6.03 to 6.04. =item * L has been upgraded from version 1.05 to 1.06. =item * L has been upgraded from version 1.80 to 1.81. =item * L has been upgraded from version 3.88 to 3.89. =item * L has been upgraded from version 3.14 to 3.15. =item * L has been upgraded from version 1.61 to 1.62. =item * L has been upgraded from version 5.20230220 to 5.20230320. =item * L has been upgraded from version 1.36 to 1.37. =item * L has been upgraded from version 2.11 to 2.12. =item * L has been upgraded from version 3.29 to 3.31. =item * L has been upgraded from version 1.302192 to 1.302194. =item * L has been upgraded from version 2.34 to 2.35. =item * L has been upgraded from version 1.65 to 1.67. =item * L has been upgraded from version 1.9772 to 1.9774. =item * L has been upgraded from version 1.62 to 1.63. =item * L has been upgraded from version 1.30 to 1.32. =back =head1 Documentation =head2 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 L. Additionally, the following selected changes have been made: =head3 F =over 4 =item * Updates to regex internals documentation. =back =head3 F =over 4 =item * Added information about unscheduled deprecations and their categories. =item * Added category information for existing scheduled deprecations. =item * Added smartmatch and apostrophe as a package separator deprecation data. =back =head3 F =over 4 =item * Smartmatch has been moved from experimental status to deprecated status. Unfortunately the experiment did not work out. =back =head3 F =over 4 =item * Documented new require hooks. =back =head3 F =over 4 =item * Documented new magic types C, C and C. =item * Documented several new or existing save stack macros: C, C, C, C =item * Documented new mortalization callback macros: C, C =back =head3 F =over 4 =item * Document the behavior of matching the empty pattern better and specify its relationship to the new C<${^LAST_SUCCESSFUL_PATTERN}> properly. =back =head3 F =over 4 =item * Added information on the new C<%{^HOOK}> interface, and the new C and C hooks which it exposes. =item * Correct information on the regex variables C<${^PREMATCH}>, C<${^MATCH}> and C<${^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. =item * Added information on the new regex variable C<${^LAST_SUCCESSFUL_PATTERN}>, which represents the pattern of the last successful regex match in scope. =back =head1 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 L. =head2 New Diagnostics =head3 New Errors =over 4 =item * L<${^HOOK}{%s} may only be a CODE reference or undef|perldiag/"${^HOOK}{%s} may only be a CODE reference or undef"> =item * L =item * L =item * L%sE|perldiag/"Too many capture groups (limit is %d) in regex m/%s/"> =back =head3 New Warnings =over 4 =item * L =back =head2 Changes to Existing Diagnostics =over 4 =item * L replaces C. =item * L replaces C. =item * L replaces C. =back =head1 Testing Tests were added and changed to reflect the other additions and changes in this release. Furthermore, these significant changes were made: =over 4 =item * Added t/op/hook/ for testing C<%{^HOOK}> related functionality. Specifically the F for testing the new require hooks. =item * Added F to test that our deprecation policies are being followed properly. =item * Fixed bugs in F and F that meant that tests in F and F were not being run during normal testing. =back =head2 Platform-Specific Notes =over 4 =item Windows =over 4 =item * C no longer creates broken sockets. [L] =item * Closing a busy pipe could cause Perl to hang. [L] =back =back =head1 Internal Changes =over 4 =item * Added C and C for better support for working with C (reference counted string/pointer value) structures which currently are used in opcodes to share filename and warning bit data in a memory efficient manner. =item * Added C and C macros, which make it possible to create a destructor which is fired at the end of the current statement. This uses the C 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. =item * Added the C<%{^HOOK}> api and related C and C for providing ways to hook selected perl functions which for one reason or another are problematic to wrap with a customized subroutine. =item * Added support for C<${^HOOK}{require__before}> which can be used to rewrite the filename that C will try to load, and also to block C from loading a specific module, even via fully qualified filename. The hook can also be used to perform "pre-require" and "post-require" actions. =item * Added support for C<${^HOOK}{require__after}> which can be used to track what modules have been required after the fact. =item * 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. =back =head1 Selected Bug Fixes =over 4 =item * In the new experimental C feature, attributes are no longer a syntax error when using the unit class syntax. [L]. =item * 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 C<$2> will not be "foo" as it once was, it will be undef. =item * 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. [L] =item * C and C have been reworked to ensure that the requested space is actually allocated. C is now an alias for C. =back =head1 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 F file in the Perl source distribution. =head1 Reporting Bugs If you find what you think is a bug, you might check the perl bug database at L. There may also be information at L, the Perl Home Page. If you believe you have an unreported bug, please open an issue at L. 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 L for details of how to report the issue. =head1 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 C program: perlthanks This will send an email to the Perl 5 Porters list with your show of thanks. =head1 SEE ALSO The F file for an explanation of how to view exhaustive details on what changed. The F file for how to build Perl. The F file for general stuff. The F and F files for copyright information. =cut