perl
view release on metacpan or search on metacpan
pod/perl5140delta.pod view on Meta::CPAN
gets to the C<eval> anyway. So C<local $@> is safe before a C<die>.
Exceptions thrown from object destructors no longer modify the C<$@>
of the surrounding context. (If the surrounding context was exception
unwinding, this used to be another way to clobber the exception being
thrown.) Previously such an exception was
sometimes emitted as a warning, and then either was
string-appended to the surrounding C<$@> or completely replaced the
surrounding C<$@>, depending on whether that exception and the surrounding
C<$@> were strings or objects. Now, an exception in this situation is
always emitted as a warning, leaving the surrounding C<$@> untouched.
In addition to object destructors, this also affects any function call
run by XS code using the C<G_KEEPERR> flag.
=item *
Warnings for C<warn> can now be objects in the same way as exceptions
for C<die>. If an object-based warning gets the default handling
of writing to standard error, it is stringified as before with the
filename and line number appended. But a C<$SIG{__WARN__}> handler now
receives an object-based warning as an object, where previously it
was passed the result of stringifying the object.
=back
=head2 Other Enhancements
=head3 Assignment to C<$0> sets the legacy process name with prctl() on Linux
On Linux the legacy process name is now set with L<prctl(2)>, in
addition to altering the POSIX name via C<argv[0]>, as Perl has done
since version 4.000. Now system utilities that read the legacy process
name such as I<ps>, I<top>, and I<killall> recognize the name you set when
assigning to C<$0>. The string you supply is truncated at 16 bytes;
this limitation is imposed by Linux.
=head3 srand() now returns the seed
This allows programs that need to have repeatable results not to have to come
up with their own seed-generating mechanism. Instead, they can use srand()
and stash the return value for future use. One example is a test program with
too many combinations to test comprehensively in the time available for
each run. It can test a random subset each time and, should there be a failure,
log the seed used for that run so this can later be used to produce the same results.
=head3 printf-like functions understand post-1980 size modifiers
Perl's printf and sprintf operators, and Perl's internal printf replacement
function, now understand the C90 size modifiers "hh" (C<char>), "z"
(C<size_t>), and "t" (C<ptrdiff_t>). Also, when compiled with a C99
compiler, Perl now understands the size modifier "j" (C<intmax_t>)
(but this is not portable).
So, for example, on any modern machine, C<sprintf("%hhd", 257)> returns "1".
=head3 New global variable C<${^GLOBAL_PHASE}>
A new global variable, C<${^GLOBAL_PHASE}>, has been added to allow
introspection of the current phase of the Perl interpreter. It's explained in
detail in L<perlvar/"${^GLOBAL_PHASE}"> and in
L<perlmod/"BEGIN, UNITCHECK, CHECK, INIT and END">.
=head3 C<-d:-foo> calls C<Devel::foo::unimport>
The syntax B<-d:foo> was extended in 5.6.1 to make B<-d:foo=bar>
equivalent to B<-MDevel::foo=bar>, which expands
internally to C<use Devel::foo 'bar'>.
Perl now allows prefixing the module name with B<->, with the same
semantics as B<-M>; that is:
=over 4
=item C<-d:-foo>
Equivalent to B<-M-Devel::foo>: expands to
C<no Devel::foo> and calls C<< Devel::foo->unimport() >>
if that method exists.
=item C<-d:-foo=bar>
Equivalent to B<-M-Devel::foo=bar>: expands to C<no Devel::foo 'bar'>,
and calls C<< Devel::foo->unimport("bar") >> if that method exists.
=back
This is particularly useful for suppressing the default actions of a
C<Devel::*> module's C<import> method whilst still loading it for debugging.
=head3 Filehandle method calls load L<IO::File> on demand
When a method call on a filehandle would die because the method cannot
be resolved and L<IO::File> has not been loaded, Perl now loads L<IO::File>
via C<require> and attempts method resolution again:
open my $fh, ">", $file;
$fh->binmode(":raw"); # loads IO::File and succeeds
This also works for globs like C<STDOUT>, C<STDERR>, and C<STDIN>:
STDOUT->autoflush(1);
Because this on-demand load happens only if method resolution fails, the
legacy approach of manually loading an L<IO::File> parent class for partial
method support still works as expected:
use IO::Handle;
open my $fh, ">", $file;
$fh->autoflush(1); # IO::File not loaded
=head3 Improved IPv6 support
The C<Socket> module provides new affordances for IPv6,
including implementations of the C<Socket::getaddrinfo()> and
C<Socket::getnameinfo()> functions, along with related constants and a
handful of new functions. See L<Socket>.
=head3 DTrace probes now include package name
The C<DTrace> probes now include an additional argument, C<arg3>, which contains
the package the subroutine being entered or left was compiled in.
pod/perl5140delta.pod view on Meta::CPAN
=back
=head2 Syntax/Parsing Bugs
=over
=item *
C<when (scalar) {...}> no longer crashes, but produces a syntax error
[perl #74114] (5.12.1).
=item *
A label right before a string eval (C<foo: eval $string>) no longer causes
the label to be associated also with the first statement inside the eval
[perl #74290] (5.12.1).
=item *
The C<no 5.13.2> form of C<no> no longer tries to turn on features or
pragmata (like L<strict>) [perl #70075] (5.12.2).
=item *
C<BEGIN {require 5.12.0}> now behaves as documented, rather than behaving
identically to C<use 5.12.0>. Previously, C<require> in a C<BEGIN> block
was erroneously executing the C<use feature ':5.12.0'> and
C<use strict> behaviour, which only C<use> was documented to
provide [perl #69050].
=item *
A regression introduced in Perl 5.12.0, making
C<< my $x = 3; $x = length(undef) >> result in C<$x> set to C<3> has been
fixed. C<$x> will now be C<undef> [perl #85508] (5.12.2).
=item *
When strict "refs" mode is off, C<%{...}> in rvalue context returns
C<undef> if its argument is undefined. An optimisation introduced in Perl
5.12.0 to make C<keys %{...}> faster when used as a boolean did not take
this into account, causing C<keys %{+undef}> (and C<keys %$foo> when
C<$foo> is undefined) to be an error, which it should be so in strict
mode only [perl #81750].
=item *
Constant-folding used to cause
$text =~ ( 1 ? /phoo/ : /bear/)
to turn into
$text =~ /phoo/
at compile time. Now it correctly matches against C<$_> [perl #20444].
=item *
Parsing Perl code (either with string C<eval> or by loading modules) from
within a C<UNITCHECK> block no longer causes the interpreter to crash
[perl #70614].
=item *
String C<eval>s no longer fail after 2 billion scopes have been
compiled [perl #83364].
=item *
The parser no longer hangs when encountering certain Unicode characters,
such as U+387 [perl #74022].
=item *
Defining a constant with the same name as one of Perl's special blocks
(like C<INIT>) stopped working in 5.12.0, but has now been fixed
[perl #78634].
=item *
A reference to a literal value used as a hash key (C<$hash{\"foo"}>) used
to be stringified, even if the hash was tied [perl #79178].
=item *
A closure containing an C<if> statement followed by a constant or variable
is no longer treated as a constant [perl #63540].
=item *
C<state> can now be used with attributes. It
used to mean the same thing as
C<my> if any attributes were present [perl #68658].
=item *
Expressions like C<< @$a > 3 >> no longer cause C<$a> to be mentioned in
the "Use of uninitialized value in numeric gt" warning when C<$a> is
undefined (since it is not part of the C<< > >> expression, but the operand
of the C<@>) [perl #72090].
=item *
Accessing an element of a package array with a hard-coded number (as
opposed to an arbitrary expression) would crash if the array did not exist.
Usually the array would be autovivified during compilation, but typeglob
manipulation could remove it, as in these two cases which used to crash:
*d = *a; print $d[0];
undef *d; print $d[0];
=item *
The B<-C> command-line option, when used on the shebang line, can now be
followed by other options [perl #72434].
=item *
The C<B> module was returning C<B::OP>s instead of C<B::LOGOP>s for
C<entertry> [perl #80622]. This was due to a bug in the Perl core,
( run in 0.670 second using v1.01-cache-2.11-cpan-5b529ec07f3 )