perl5220delta (1) Linux Manual Page
NAME
perl5220delta – what is new for perl v5.22.0
DESCRIPTION
This document describes differences between the 5.20.0 release and the 5.22.0 release.
If you are upgrading from an earlier release such as 5.18.0, first read perl5200delta, which describes differences between 5.18.0 and 5.20.0.
Core Enhancements
New bitwise operators
A new experimental facility has been added that makes the four standard bitwise operators ("& | ^ ~") treat their operands consistently as numbers, and introduces four new dotted operators ("&. |. ^. ~.") that treat their operands consistently as strings. The same applies to the assignment variants ("&= |= ^= &.= |.= ^.=").
To use this, enable the “bitwise” feature and disable the “experimental::bitwise” warnings category. See “Bitwise String Operators” in perlop for details. [perl #123466] <https://rt.perl.org/Ticket/Display.html?id=123466>.
New double-diamond operator
"<<>>" is like "<>" but uses three-argument "open" to open each file in @ARGV. This means that each element of @ARGV will be treated as an actual file name, and "|foo" won’t be treated as a pipe open.
New boundaries in regular expressions
"qr/{gcb}/"
"gcb" stands for Grapheme Cluster Boundary. It is a Unicode property that finds the boundary between sequences of characters that look like a single character to a native speaker of a language. Perl has long had the ability to deal with these through the "\X" regular escape sequence. Now, there is an alternative way of handling these. See “{}, , \B{}, \B” in perlrebackslash for details.
"qr/{wb}/"
"wb" stands for Word Boundary. It is a Unicode property that finds the boundary between words. This is similar to the plain "" (without braces) but is more suitable for natural language processing. It knows, for example, that apostrophes can occur in the middle of words. See “{}, , \B{}, \B” in perlrebackslash for details.
"qr/{sb}/"
"sb" stands for Sentence Boundary. It is a Unicode property to aid in parsing natural language sentences. See “{}, , \B{}, \B” in perlrebackslash for details.
Non-Capturing Regular Expression Flag
Regular expressions now support a "/n" flag that disables capturing and filling in $1, $2, etc inside of groups:
"hello" =~ /(hi|hello)/n; # $1 is not set
This is equivalent to putting "?:" at the beginning of every capturing group.
See “n” in perlre for more information.
use re ‘strict’
This applies stricter syntax rules to regular expression patterns compiled within its scope. This will hopefully alert you to typos and other unintentional behavior that backwards-compatibility issues prevent us from reporting in normal regular expression compilations. Because the behavior of this is subject to change in future Perl releases as we gain experience, using this pragma will raise a warning of category "experimental::re_strict". See ‘strict’ in re.
Unicode 7.0 (with correction) is now supported
For details on what is in this release, see <http://www.unicode.org/versions/Unicode7.0.0/>. The version of Unicode 7.0 that comes with Perl includes a correction dealing with glyph shaping in Arabic (see <http://www.unicode.org/errata/#current_errata>).
use locale can restrict which locale categories are affected
It is now possible to pass a parameter to "use locale" to specify a subset of locale categories to be locale-aware, with the remaining ones unaffected. See “The ”use locale“ pragma” in perllocale for details.
Perl now supports POSIX 2008 locale currency additions
On platforms that are able to handle POSIX.1-2008, the hash returned by "POSIX::localeconv()" includes the international currency fields added by that version of the POSIX standard. These are "int_n_cs_precedes", "int_n_sep_by_space", "int_n_sign_posn", "int_p_cs_precedes", "int_p_sep_by_space", and "int_p_sign_posn".
Better heuristics on older platforms for determining locale UTF-8ness
On platforms that implement neither the C99 standard nor the POSIX 2001 standard, determining if the current locale is UTF-8 or not depends on heuristics. These are improved in this release.
Aliasing via reference
Variables and subroutines can now be aliased by assigning to a reference:
\$c = \$d;
\&x = \&y;
Aliasing can also be accomplished by using a backslash before a "foreach" iterator variable; this is perhaps the most useful idiom this feature provides:
foreach \%hash (@array_of_hash_refs) { ... }
This feature is experimental and must be enabled via "use feature 'refaliasing'". It will warn unless the "experimental::refaliasing" warnings category is disabled.
See “Assigning to References” in perlref
prototype with no arguments
"prototype()" with no arguments now infers $_. [perl #123514] <https://rt.perl.org/Ticket/Display.html?id=123514>.
New :const subroutine attribute
The "const" attribute can be applied to an anonymous subroutine. It causes the new sub to be executed immediately whenever one is created (i.e. when the "sub" expression is evaluated). Its value is captured and used to create a new constant subroutine that is returned. This feature is experimental. See “Constant Functions” in perlsub.
fileno now works on directory handles
When the relevant support is available in the operating system, the "fileno" builtin now works on directory handles, yielding the underlying file descriptor in the same way as for filehandles. On operating systems without such support, "fileno" on a directory handle continues to return the undefined value, as before, but also sets $! to indicate that the operation is not supported.
Currently, this uses either a "dd_fd" member in the OS "DIR" structure, or a dirfd(3) function as specified by POSIX.1-2008.
List form of pipe open implemented for Win32
The list form of pipe:
open my $fh, "-|", "program", @arguments;
is now implemented on Win32. It has the same limitations as "system LIST" on Win32, since the Win32 API doesn’t accept program arguments as a list.
Assignment to list repetition
"(...) x ..." can now be used within a list that is assigned to, as long as the left-hand side is a valid lvalue. This allows "(undef,undef,$foo) = that_function()" to be written as "((undef)x2, $foo) = that_function()".
Infinity and NaN (not-a-number) handling improved
Floating point values are able to hold the special values infinity, negative infinity, and NaN (not-a-number). Now we more robustly recognize and propagate the value in computations, and on output normalize them to the strings "Inf", "-Inf", and "NaN".
See also the POSIX enhancements.
Floating point parsing has been improved
Parsing and printing of floating point values has been improved.
As a completely new feature, hexadecimal floating point literals (like "0x1.23p-4") are now supported, and they can be output with "printf "%a"". See “Scalar value constructors” in perldata for more details.
Packing infinity or not-a-number into a character is now fatal
Before, when trying to pack infinity or not-a-number into a (signed) character, Perl would warn, and assumed you tried to pack 0xFF; if you gave it as an argument to "chr", "U+FFFD" was returned.
But now, all such actions ("pack", "chr", and "print '%c'") result in a fatal error.
Experimental C Backtrace API
Perl now supports (via a C level API) retrieving the C level backtrace (similar to what symbolic debuggers like gdb do).
The backtrace returns the stack trace of the C call frames, with the symbol names (function names), the object names (like “perl”), and if it can, also the source code locations (file:line).
The supported platforms are Linux and OS X (some *BSD might work at least partly, but they have not yet been tested).
The feature needs to be enabled with "Configure -Dusecbacktrace".
See “C backtrace” in perlhacktips for more information.
Security
Perl is now compiled with -fstack-protector-strong if available
Perl has been compiled with the anti-stack-smashing option "-fstack-protector" since 5.10.1. Now Perl uses the newer variant called "-fstack-protector-strong", if available.
The Safe module could allow outside packages to be replaced
Critical bugfix: outside packages could be replaced. Safe has been patched to 2.38 to address this.
Perl is now always compiled with -D_FORTIFY_SOURCE=2 if available
The ‘code hardening’ option called "_FORTIFY_SOURCE", available in gcc 4.*, is now always used for compiling Perl, if available.
Note that this isn’t necessarily a huge step since in many platforms the step had already been taken several years ago: many Linux distributions (like Fedora) have been using this option for Perl, and OS X has enforced the same for many years.
Incompatible Changes
Subroutine signatures moved before attributes
The experimental sub signatures feature, as introduced in 5.20, parsed signatures after attributes. In this release, following feedback from users of the experimental feature, the positioning has been moved such that signatures occur after the subroutine name (if any) and before the attribute list (if any).
& and \& prototypes accepts only subs
The "&" prototype character now accepts only anonymous subs ("sub {...}"), things beginning with "\&", or an explicit "undef". Formerly it erroneously also allowed references to arrays, hashes, and lists. [perl #4539] <https://rt.perl.org/Ticket/Display.html?id=4539>. [perl #123062] <https://rt.perl.org/Ticket/Display.html?id=123062>. [perl #123062] <https://rt.perl.org/Ticket/Display.html?id=123475>.
In addition, the "\&" prototype was allowing subroutine calls, whereas now it only allows subroutines: &foo is still permitted as an argument, while "&foo()" and "foo()" no longer are. [perl #77860] <https://rt.perl.org/Ticket/Display.html?id=77860>.
use encoding is now lexical
The encoding pragma’s effect is now limited to lexical scope. This pragma is deprecated, but in the meantime, it could adversely affect unrelated modules that are included in the same program; this change fixes that.
List slices returning empty lists
List slices now return an empty list only if the original list was empty (or if there are no indices). Formerly, a list slice would return an empty list if all indices fell outside the original list; now it returns a list of "undef" values in that case. [perl #114498] <https://rt.perl.org/Ticket/Display.html?id=114498>.
\N{} with a sequence of multiple spaces is now a fatal error
E.g. "\N{TOO MANY SPACES}" or "\N{TRAILING SPACE }". This has been deprecated since v5.18.
use UNIVERSAL ‘…’ is now a fatal error
Importing functions from "UNIVERSAL" has been deprecated since v5.12, and is now a fatal error. "use UNIVERSAL" without any arguments is still allowed.
