This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perldelta.pod - add more docs on %{^HOOK}, update github links,
[perl5.git] / pod / perldelta.pod
CommitLineData
0382c61d 1=encoding utf8
7b0fb693 2
0382c61d 3=head1 NAME
7b0fb693 4
9865eed8 5perldelta - what is new for perl v5.37.10
aae76867 6
9f2eb154 7=head1 DESCRIPTION
aae76867 8
9865eed8 9This document describes differences between the 5.37.9 release and the 5.37.10
9f2eb154 10release.
aae76867 11
9865eed8
KE
12If you are upgrading from an earlier release such as 5.37.8, first read
13L<perl5379delta>, which describes differences between 5.37.8 and 5.37.9.
8cf9e0b7 14
9865eed8 15=head1 Core Enhancements
0f2b2db7 16
c61be20d
PE
17=head2 Some C<goto>s are now permitted in C<defer> and C<finally> blocks
18
19Perl version 5.36.0 added C<defer> blocks and permitted the C<finally> keyword
20to also add similar behaviour to C<try>/C<catch> syntax. These did not permit
21any C<goto> expression within the body, as it could have caused control flow
22to jump out of the block. Now, some C<goto> expressions are allowed, if they
23have a constant target label, and that label is found within the block.
24
25 use feature 'defer';
26
27 defer {
28 goto LABEL;
29 print "This does not execute\n";
30 LABEL: print "This does\n";
31 }
32
d80a076d
YO
33=head2 New regexp variable ${^LAST_SUCCESSFUL_PATTERN}
34
35This allows access to the last succesful pattern that matched in the current scope.
36Many aspects of the regex engine refer to the "last successful pattern". The empty
37pattern reuses it, and all of the magic regex vars relate to it. This allows
38access to its pattern. The following code
39
40 if (m/foo/ || m/bar/) {
41 s//PQR/;
42 }
43
44can be rewritten as follows
45
46 if (m/foo/ || m/bar/) {
47 s/${^LAST_SUCCESSFUL_PATTERN}/PQR/;
48 }
49
50and it will do the exactly same thing.
51
655778a2 52=head2 Deprecation warnings now have specific subcategories
b87acd3b 53
655778a2
YO
54As of 5.37.10 all deprecation warnings will have their own specific
55deprecation category which can be disabled individually. You can see a
56list of all deprecated features in L<perldeprecation>, and in
57L<warnings>. The following list is from L<warnings>:
b87acd3b 58
655778a2
YO
59 +- deprecated ----+
60 | |
61 | +- deprecated::apostrophe_as_package_separator
62 | |
63 | +- deprecated::delimiter_will_be_paired
64 | |
65 | +- deprecated::dot_in_inc
66 | |
67 | +- deprecated::goto_construct
68 | |
69 | +- deprecated::smartmatch
70 | |
71 | +- deprecated::unicode_property_name
72 | |
73 | +- deprecated::version_downgrade
dcc59d83 74
655778a2
YO
75It is still possible to disable all deprecation warnings in a single
76statement with
b87acd3b 77
655778a2 78 no warnings 'deprecated';
b87acd3b 79
655778a2
YO
80but as of 5.37.10 it is possible to have a finer grained control. As
81has historically been the case these warnings are automatically
82enabled with
bf44733f 83
655778a2 84 use warnings;
25948dfb 85
4e4d066b
YO
86=head2 %{^HOOK} API introduced
87
88For various reasons it can be difficult to create subroutine wrappers
89for some of perls keywords. Any keyword which has an undefined
90prototype simply cannot be wrapped with a subroutine, and some keywords
91which perl permits to be wrapped are in practice very tricky to wrap.
92For example C<require> is tricky to wrap, it is possible but doing so
93changes the stack depth, and the standard methods of exporting assume
94that they will be exporting to a package at certain stack depth up the
95stack, and the wrapper will thus change where functions are exported to
96unless implemented with a great deal of care. This can be very awkward
97to deal with.
98
99Accordingly we have introduced a new hash called C<%{^HOOK}> which is
100intended to facilitate such cases. When a keyword supports any kind of
101special hook then the hook will live in this new hash. Hooks in this
102hash will be named after the function they are called by, followed by
103two underbars and then the phase they are executed in, currently either
104before or after the keyword is executed.
105
106In this initial release we support two hooks C<require__before> and
107C<require__after>. These are provided to make it easier to perform tasks
108before and after a require statement.
109
110See L<perlvar> for more details.
dcc59d83 111
9865eed8 112=head1 Modules and Pragmata
dcc59d83 113
4e4d066b
YO
114=head2 Updated Modules and Pragmata
115
116=over 4
dcc59d83 117
4e4d066b 118=item *
dcc59d83 119
4e4d066b 120L<Benchmark> has been upgraded from version 1.23 to 1.24.
dcc59d83 121
4e4d066b 122=item *
dcc59d83 123
4e4d066b 124L<Class::Struct> has been upgraded from version 0.67 to 0.68.
dcc59d83
KE
125
126=item *
127
4e4d066b 128L<Config::Perl::V> has been upgraded from version 0.35 to 0.36.
dcc59d83 129
4e4d066b 130=item *
dcc59d83 131
4e4d066b 132L<Data::Dumper> has been upgraded from version 2.187 to 2.188.
dcc59d83 133
4e4d066b
YO
134=item *
135
136L<Digest::SHA> has been upgraded from version 6.03 to 6.04.
137
138=item *
139
140L<Env> has been upgraded from version 1.05 to 1.06.
141
142=item *
143
144L<feature> has been upgraded from version 1.80 to 1.81.
145
146=item *
147
148L<File::Spec> has been upgraded from version 3.88 to 3.89.
149
150=item *
151
152L<Net::Cmd> has been upgraded from version 3.14 to 3.15.
153
154=item *
155
156L<Math::Complex> has been upgraded from version 1.61 to 1.62.
dcc59d83
KE
157
158=item *
159
655778a2 160L<Module::CoreList> has been upgraded from version 5.20230220 to 5.20230320.
dcc59d83 161
655778a2 162=item *
dcc59d83 163
4e4d066b
YO
164L<overload> has been upgraded from version 1.36 to 1.37.
165
166=item *
167
168L<POSIX> has been upgraded from version 2.11 to 2.12.
169
170=item *
171
172L<Storable> has been upgraded from version 3.29 to 3.31.
173
174=item *
175
176L<Test::Simple> has been upgraded from version 1.302192 to 1.302194.
dcc59d83 177
655778a2 178=item *
dcc59d83 179
4e4d066b 180L<threads> has been upgraded from version 2.34 to 2.35.
bacfb30b 181
ae98afd8 182=item *
8f4d4ed2 183
4e4d066b
YO
184L<threads::shared> has been upgraded from version 1.65 to 1.67.
185
186=item *
187
188L<Time::HiRes> has been upgraded from version 1.9772 to 1.9774.
189
190=item *
191
192L<warnings> has been upgraded from version 1.62 to 1.63.
193
194=item *
195
196L<XS::APItest> has been upgraded from version 1.30 to 1.32.
b87acd3b 197
4d2e6572
RB
198=back
199
200=head1 Documentation
201
4d2e6572
RB
202=head2 Changes to Existing Documentation
203
204We have attempted to update the documentation to reflect the changes
205listed in this document. If you find any we have missed, open an issue
4e4d066b 206at L<https://github.com/Perl/perl5/issues/new/choose>.
4d2e6572 207
9865eed8 208Additionally, the following selected changes have been made:
43ea14c2 209
655778a2 210=head3 F<pod/perldebguts.pod>
4d2e6572
RB
211
212=over 4
2feb1615 213
b87acd3b 214=item *
2feb1615 215
655778a2 216Updates to regex internals documentation.
4d2e6572
RB
217
218=back
219
655778a2 220=head3 F<pod/perldeprecation.pod>
4d2e6572 221
655778a2 222=over 4
4d2e6572 223
655778a2 224=item *
9865eed8 225
655778a2 226Added information about unscheduled deprecations and their categories.
4d2e6572 227
655778a2 228=item *
9865eed8 229
655778a2
YO
230Added category information for existing scheduled deprecations.
231
232=item *
233
234Added smartmatch and apostrophe as a package separator deprecation data.
235
236=back
237
238=head3 F<pod/perlexperiment.pod>
4d2e6572
RB
239
240=over 4
b694b46b
RL
241
242=item *
243
655778a2
YO
244Smartmatch has been moved from experimental status to deprecated status.
245Unfortunately the experiment did not work out.
4d2e6572 246
9865eed8 247=back
f101e19a 248
655778a2 249=head3 F<pod/perlexperiment.pod>
4d2e6572 250
9865eed8 251=over 4
4d2e6572 252
43ea14c2 253=item *
4d2e6572 254
655778a2 255Documented new require hooks.
4d2e6572 256
9865eed8 257=back
43ea14c2 258
655778a2 259=head3 F<pod/perlguts.pod>
43ea14c2 260
9865eed8 261=over 4
4d2e6572
RB
262
263=item *
264
655778a2
YO
265Documented new magic types C<PERL_MAGIC_destruct>, C<PERL_MAGIC_hook> and
266C<PERL_MAGIC_hookelem>.
267
268=item *
269
270Documented several new or existing save stack macros: C<SAVERCPV()>,
271C<SAVEGENERICSV()>, C<SAVEFREEPV()>, C<SAVEFREERCPV()>
272
273=item *
274
275Documented new mortalization callback macros: C<MORTALSVFUNC_X()>,
276C<MORTALDESTRUCTOR_SV()>
f101e19a 277
9865eed8 278=back
b694b46b 279
655778a2 280=head3 F<pod/perlop.pod>
4d2e6572 281
655778a2 282=over 4
4d2e6572 283
655778a2 284=item *
4d2e6572 285
655778a2
YO
286Document the behavior of matching the empty pattern better and specify
287its relationship to the new C<${^LAST_SUCCESSFUL_PATTERN}> properly.
288
289=back
290
291=head3 F<pod/perlvar.pod>
4d2e6572 292
9865eed8 293=over 4
4d2e6572 294
43ea14c2 295=item *
4d2e6572 296
655778a2
YO
297Added information on the new C<%{^HOOK}> interface, and the new
298C<require__before> and C<require__after> hooks which it exposes.
299
300=item *
301
302Correct information on the regex variables C<${^PREMATCH}>, C<${^MATCH}>
303and C<${^POSTMATCH}>, all of which were incorrectly documented due to an
304oversight. Specifically they only work properly after a regex operation
305that used the /p modifier to enable them.
306
307=item *
308
309Added information on the new regex variable C<${^LAST_SUCCESSFUL_PATTERN}>,
310which represents the pattern of the last successful regex match in scope.
4d2e6572 311
9865eed8 312=back
4d2e6572 313
655778a2
YO
314=head1 Diagnostics
315
316The following additions or changes have been made to diagnostic output,
317including warnings and fatal error messages. For the complete list of
318diagnostic messages, see L<perldiag>.
319
655778a2 320=head2 New Diagnostics
43ea14c2 321
655778a2 322=head3 New Errors
43ea14c2 323
9865eed8 324=over 4
43ea14c2
KE
325
326=item *
327
655778a2 328L<${^HOOK}{%s} may only be a CODE reference or undef|perldiag/"${^HOOK}{%s} may only be a CODE reference or undef">
43ea14c2 329
655778a2 330=item *
43ea14c2 331
655778a2 332L<Attempt to set unknown hook '%s' in %{^HOOK}|perldiag/"Attempt to set unknown hook '%s' in %{^HOOK}">
43ea14c2 333
655778a2 334=item *
43ea14c2 335
655778a2 336L<Missing or undefined argument to %s via %{^HOOK}{require__before}|perldiag/"Missing or undefined argument to %s via %{^HOOK}{require__before}">
43ea14c2 337
655778a2 338=item *
43ea14c2 339
655778a2 340L<Too many capture groups (limit is %d) in regex mE<sol>%sE<sol>|perldiag/"Too many capture groups (limit is %d) in regex m/%s/">
43ea14c2 341
655778a2 342=back
43ea14c2 343
655778a2 344=head3 New Warnings
43ea14c2 345
9865eed8 346=over 4
43ea14c2
KE
347
348=item *
349
655778a2 350L<Can't call destructor for 0x%p in global destruction|perldiag/"Can't call destructor for 0x%p in global destruction">
43ea14c2 351
9865eed8 352=back
43ea14c2 353
655778a2 354=head2 Changes to Existing Diagnostics
43ea14c2 355
655778a2 356=over 4
43ea14c2 357
655778a2 358=item *
43ea14c2 359
655778a2 360L<given is deprecated|perldiag/"given is deprecated"> replaces C<given is experimental>.
43ea14c2 361
655778a2 362=item *
43ea14c2 363
655778a2 364L<when is deprecated|perldiag/"when is deprecated"> replaces C<when is experimental>.
43ea14c2 365
655778a2 366=item *
43ea14c2 367
655778a2 368L<Smartmatch is deprecated|perldiag/"Smartmatch is deprecated"> replaces C<Smartmatch is experimental>.
4d2e6572
RB
369
370=back
371
655778a2 372=head1 Testing
43ea14c2 373
655778a2
YO
374Tests were added and changed to reflect the other additions and
375changes in this release. Furthermore, these significant changes were
376made:
43ea14c2 377
9865eed8 378=over 4
43ea14c2 379
655778a2
YO
380=item *
381
382Added t/op/hook/ for testing C<%{^HOOK}> related functionality. Specifically
383the F<t/op/hook/require.t> for testing the new require hooks.
384
385=item *
43ea14c2 386
655778a2
YO
387Added F<t/op/deprecation.t> to test that our deprecation policies are being
388followed properly.
389
390=item *
391
392Fixed bugs in F<t/harness> and F<t/TEST> that meant that tests in F<t/test_pl> and
393F<t/class> were not being run during normal testing.
43ea14c2
KE
394
395=back
b694b46b 396
9865eed8 397=head2 Platform-Specific Notes
b694b46b 398
9865eed8 399=over 4
43ea14c2 400
8552f09f 401=item Windows
43ea14c2 402
8552f09f
TK
403=over 4
404
405=item *
406
4e4d066b 407C<POSIX::dup2> no longer creates broken sockets. [L<GH #20920|https://github.com/Perl/perl5/issues/20920>]
8552f09f
TK
408
409=item *
410
4e4d066b 411Closing a busy pipe could cause Perl to hang. [L<GH #19963|https://github.com/Perl/perl5/issues/19963>]
8552f09f
TK
412
413=back
314388b6 414
4d2e6572 415=back
314388b6 416
43ea14c2 417=head1 Internal Changes
4d2e6572 418
655778a2 419=over 4
314388b6 420
655778a2 421=item *
314388b6 422
655778a2
YO
423Added C<SAVERCPV()> and C<SAVEFREERCPV()> for better support for working
424with C<RCPV> (reference counted string/pointer value) structures which
425currently are used in opcodes to share filename and warning bit data in
426a memory efficient manner.
314388b6 427
1ca0f119
KW
428=item *
429
655778a2
YO
430Added C<MORTALSVFUNC_SV()> and C<MORTALDESTRUCTOR_SV()> macros, which
431make it possible to create a destructor which is fired at the end of
432the current statement. This uses the C<PERL_MAGIC_destruct> magic to
433use "free" magic to trigger an action when a variable is freed. The
434action can be specified as a C function or as a Perl code reference.
1ca0f119 435
655778a2 436=item *
314388b6 437
655778a2
YO
438Added the C<%{^HOOK}> api and related C<PERL_MAGIC_hook> and
439C<PERL_MAGIC_hookelem> for providing ways to hook selected perl functions
440which for one reason or another are problematic to wrap with a customized
441subroutine.
442
443=item *
444
445Added support for C<${^HOOK}{require__before}> which can be used to
446rewrite the filename that C<require> will try to load, and also to block
447C<require> from loading a specific module, even via fully qualified
448filename. The hook can also be used to perform "pre-require" and
449"post-require" actions.
4d2e6572 450
655778a2
YO
451=item *
452
453Added support for C<${^HOOK}{require__after}> which can be used to
454track what modules have been required after the fact.
4d2e6572 455
655778a2 456=item *
e95dc77e 457
655778a2
YO
458Regular expression opcodes (regops) now use a standardized structure
459layout that uses unions to expose data in different format. This means
460it should be much easier to extend or modify regops to use more memory.
461This has been used to make a number of regops track how many parens
462they contain.
463
464=back
465
466=head1 Selected Bug Fixes
4d2e6572 467
9865eed8 468=over 4
4d2e6572 469
4202141d
TC
470=item *
471
edcf480e
AJ
472In the new experimental C<class> feature, attributes are no longer a syntax
473error when using the unit class syntax.
4e4d066b 474[L<GH #20888|https://github.com/Perl/perl5/issues/20888>].
edcf480e
AJ
475
476=item *
477
655778a2
YO
478A number of bugs related to capture groups in quantified groups in regular
479expression have been fixed, especially in alternations. For example in
480a pattern like:
4202141d 481
655778a2
YO
482 "foobazfoobar" =~ /((foo)baz|foo(bar))+/
483
484the regex variable C<$2> will not be "foo" as it once was, it will be undef.
4202141d 485
655778a2 486=item *
828bae55 487
655778a2
YO
488Bugs with regex backreference operators that are inside of a capture
489group have been fixed. For instance:
828bae55 490
655778a2 491 "xa=xaaa" =~ /^(xa|=?\1a){2}\z/
0a73ee9e 492
4e4d066b 493will now correctly not match. [L<GH #10073|https://github.com/Perl/perl5/issues/10073>]
0a73ee9e
YO
494
495=item *
496
655778a2
YO
497C<SSGROW()> and C<SSCHECK()> have been reworked to ensure that the requested
498space is actually allocated. C<SSCHECK()> is now an alias for C<SSGROW()>.
0a73ee9e 499
9865eed8 500=back
0a73ee9e 501
655778a2 502=head1 Acknowledgements
61241b1b 503
655778a2
YO
504Perl 5.37.10 represents approximately 4 weeks of development since Perl
5055.37.9 and contains approximately 23,000 lines of changes across 360 files
506from 21 authors.
61241b1b 507
655778a2
YO
508Excluding auto-generated files, documentation and release tools, there were
509approximately 6,000 lines of changes to 220 .pm, .t, .c and .h files.
b694b46b 510
655778a2
YO
511Perl continues to flourish into its fourth decade thanks to a vibrant
512community of users and developers. The following people are known to have
513contributed the improvements that became Perl 5.37.10:
c0b38a2b 514
655778a2
YO
515Arne Johannessen, Craig A. Berry, Dan Jacobson, David Mitchell, Elvin
516Aslanov, Graham Knop, James E Keenan, James Raspass, Jon Gentle, Karen
517Etheridge, Karl Williamson, Leon Timmermans, Lukas Mai, Paul Evans, Philippe
518Bruhat (BooK), Richard Leach, Steve Hay, Tomasz Konojacki, Tony Cook, Yves
519Orton, Zefram.
4d2e6572 520
655778a2
YO
521The list above is almost certainly incomplete as it is automatically
522generated from version control history. In particular, it does not include
523the names of the (very much appreciated) contributors who reported issues to
524the Perl bug tracker.
c0b38a2b 525
655778a2
YO
526Many of the changes included in this version originated in the CPAN modules
527included in Perl's core. We're grateful to the entire CPAN community for
528helping Perl to flourish.
9f2eb154 529
655778a2
YO
530For a more complete list of all of Perl's historical contributors, please
531see the F<AUTHORS> file in the Perl source distribution.
8424e368 532
44691e6f
AB
533=head1 Reporting Bugs
534
6acd8d81
SH
535If you find what you think is a bug, you might check the perl bug database
536at L<https://github.com/Perl/perl5/issues>. There may also be information at
46a21c0a 537L<http://www.perl.org/>, the Perl Home Page.
44691e6f 538
8166b4e0 539If you believe you have an unreported bug, please open an issue at
0382c61d 540L<https://github.com/Perl/perl5/issues>. Be sure to trim your bug down to a
8166b4e0 541tiny but sufficient test case.
44691e6f 542
87c118b9 543If the bug you are reporting has security implications which make it
8166b4e0 544inappropriate to send to a public issue tracker, then see
6acd8d81
SH
545L<perlsec/SECURITY VULNERABILITY CONTACT INFORMATION>
546for details of how to report the issue.
44691e6f 547
390ae6f9
S
548=head1 Give Thanks
549
6acd8d81
SH
550If you wish to thank the Perl 5 Porters for the work we had done in Perl 5,
551you can do so by running the C<perlthanks> program:
390ae6f9
S
552
553 perlthanks
554
555This will send an email to the Perl 5 Porters list with your show of thanks.
556
44691e6f
AB
557=head1 SEE ALSO
558
e08634c5
SH
559The F<Changes> file for an explanation of how to view exhaustive details on
560what changed.
44691e6f
AB
561
562The F<INSTALL> file for how to build Perl.
563
564The F<README> file for general stuff.
565
566The F<Artistic> and F<Copying> files for copyright information.
567
568=cut