This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perldelta: Incorporate the local $_ entry from 658a9f3
[perl5.git] / pod / perldelta.pod
index 77ad4da..2ea8a86 100644 (file)
@@ -688,6 +688,19 @@ such as signal handlers being wiped when modules were loaded, etc.
 This has been fixed (or the feature has been removed, depending on how you see
 it).
 
+=head3 local($_) will strip all magic from $_
+
+local() on scalar variables will give them a new value, but keep all
+their magic intact.  This has proven to be problematic for the default
+scalar variable $_, where L<perlsub> recommends that any subroutine
+that assigns to $_ should localize it first.  This would throw an
+exception if $_ is aliased to a read-only variable, and could have
+various unintentional side-effects in general.
+
+Therefore, as an exception to the general rule, local($_) will not
+only assign a new value to $_, but also remove all existing magic from
+it as well.
+
 =head2 Changes to Syntax or to Perl Operators
 
 =head3 C<given> return values
@@ -3872,6 +3885,10 @@ by C<splice @ISA> are respected by method calls) [perl #78400].
 In-memory files created by C<open $fh, 'E<gt>' \$buffer> were not calling
 FETCH/STORE at all [perl #43789] (5.12.2).
 
+=item *
+
+utf8::is_utf8 now respects get-magic (e.g. $1) (5.12.1).
+
 =back
 
 =item *
@@ -3935,14 +3952,10 @@ name was not tainted.
 
 =item *
 
-C<sprintf> now dies when passed a tainted scalar for the format. It did
+C<sprintf> now dies when passed a tainted scalar for the format.  It did
 already die for arbitrary expressions, but not for simple scalars
 [perl #82250].
 
-=item *
-
-utf8::is_utf8 now respects get-magic (e.g. $1) (5.12.1).
-
 =back
 
 =head2 The Debugger
@@ -3978,8 +3991,8 @@ already have values when $^P is assigned to [perl #72422].
 
 C<#line> directives in string evals were not properly updating the arrays
 of lines of code (C<< @{"_<..."} >>) that the debugger (or any debugging or
-profiling module) uses. In threaded builds, they were not being updated at
-all. In non-threaded builds, the line number was ignored, so any change to
+profiling module) uses.  In threaded builds, they were not being updated at
+all.  In non-threaded builds, the line number was ignored, so any change to
 the existing line number would cause the lines to be misnumbered
 [perl #79442].
 
@@ -4005,8 +4018,9 @@ Creating a new thread when directory handles were open used to cause a
 crash, because the handles were not cloned, but simply passed to the new
 thread, resulting in a double free.
 
-Now directory handles are cloned properly, on systems that have a C<fchdir>
-function. On other systems, new threads simply do not inherit directory
+Now directory handles are cloned properly, on Windows
+and on systems that have a C<fchdir> function.  On other
+systems, new threads simply do not inherit directory
 handles from their parent threads [perl #75154].
 
 =item *
@@ -4022,7 +4036,8 @@ separator), had the wrong reference count in child threads.
 =item *
 
 Perl now does a timely cleanup of SVs that are cloned into a new thread but
-then discovered to be orphaned (i.e., their owners are I<not> cloned). This
+then discovered to be orphaned (i.e., their
+owners are I<not> cloned).  This
 eliminates several "scalars leaked" warnings when joining threads.
 
 =back
@@ -4093,7 +4108,7 @@ they were blocked before by C<POSIX::sigprocmask> [perl #82040].
 =item *
 
 A signal handler called within a signal handler could cause leaks or
-double-frees.  Now fixed. [perl #76248].
+double-frees.  Now fixed [perl #76248].
 
 =back
 
@@ -4111,7 +4126,7 @@ L<substr()|perlfunc/"substr EXPR,OFFSET,LENGTH,REPLACEMENT">,
 L<pos()|perlfunc/"index STR,SUBSTR,POSITION">, L<keys()|perlfunc/"keys HASH">,
 and L<vec()|perlfunc/"vec EXPR,OFFSET,BITS"> could, when used in combination
 with lvalues, result in leaking the scalar value they operate on, and cause its
-destruction to happen too late. This has now been fixed.
+destruction to happen too late.  This has now been fixed.
 
 =item *
 
@@ -4288,7 +4303,7 @@ The ref types in the typemap for XS bindings now support magical variables
 =item *
 
 C<sv_catsv_flags> no longer calls C<mg_get> on its second argument (the
-source string) if the flags passed to it do not include SV_GMAGIC. So it
+source string) if the flags passed to it do not include SV_GMAGIC.  So it
 now matches the documentation.
 
 =item *
@@ -4400,6 +4415,12 @@ You can now use the C<keys>, C<values>, C<each> builtin functions on arrays
 This is actually a change introduced in perl 5.12.0, but it was missed from
 that release's perldelta.
 
+=head2 C<split> and C<@_>
+
+C<split> no longer modifies C<@_> when called in scalar or void context.
+In void context it now produces a "Useless use of split" warning.
+This was also a perl 5.12.0 changed which missed the perldelta.
+
 =head1 Obituary
 
 Randy Kobes, creator of the kobesearch alternative to search.cpan.org and