perl5120delta - what is new for perl v5.12.0
Translations of this material:
- into Russian: perl5120delta — что нового в perl v.5.12.0. 2% translated in draft.
-
Submitted for translation by perl5doc.ru 05.07.2010
Text
=encoding utf8
=head1 NAME
perl5120delta - what is new for perl v5.12.0
=head1 DESCRIPTION
This document describes differences between the 5.10.0 release and the
5.12.0 release.
Many of the bug fixes in 5.12.0 are already included in the 5.10.1
maintenance release.
You can see the list of those changes in the 5.10.1 release notes
(L<perl5101delta>).
=head1 Core Enhancements
=head2 New C<package NAME VERSION> syntax
This new syntax allows a module author to set the $VERSION of a namespace
when the namespace is declared with 'package'. It eliminates the need
for C<our $VERSION = ...> and similar constructs. E.g.
package Foo::Bar 1.23;
# $Foo::Bar::VERSION == 1.23
There are several advantages to this:
=over
=item *
C<$VERSION> is parsed in exactly the same way as C<use NAME VERSION>
=item *
C<$VERSION> is set at compile time
=item *
C<$VERSION> is a version object that provides proper overloading of
comparison operators so comparing C<$VERSION> to decimal (1.23) or
dotted-decimal (v1.2.3) version numbers works correctly.
=item *
Eliminates C<$VERSION = ...> and C<eval $VERSION> clutter
=item *
As it requires VERSION to be a numeric literal or v-string
literal, it can be statically parsed by toolchain modules
without C<eval> the way MM-E<gt>parse_version does for C<$VERSION = ...>
=back
It does not break old code with only C<package NAME>, but code that uses
C<package NAME VERSION> will need to be restricted to perl 5.12.0 or newer
This is analogous to the change to C<open> from two-args to three-args.
Users requiring the latest Perl will benefit, and perhaps after several
years, it will become a standard practice.
However, C<package NAME VERSION> requires a new, 'strict' version
number format. See L<"Version number formats"> for details.
=head2 The C<...> operator
A new operator, C<...>, nicknamed the Yada Yada operator, has been added.
It is intended to mark placeholder code that is not yet implemented.
See L<perlop/"Yada Yada Operator">.
=head2 Implicit strictures
Using the C<use VERSION> syntax with a version number greater or equal
to 5.11.0 will lexically enable strictures just like C<use strict>
would do (in addition to enabling features.) The following:
use 5.12.0;
means:
use strict;
use feature ':5.12';
=head2 Unicode improvements
Perl 5.12 comes with Unicode 5.2, the latest version available to
us at the time of release. This version of Unicode was released in
October 2009. See L<http://www.unicode.org/versions/Unicode5.2.0> for
further details about what's changed in this version of the standard.
See L<perlunicode> for instructions on installing and using other versions
of Unicode.
Additionally, Perl's developers have significantly improved Perl's Unicode
implementation. For full details, see L</Unicode overhaul> below.
=head2 Y2038 compliance
Perl's core time-related functions are now Y2038 compliant. (It may not mean much to you, but your kids will love it!)
=head2 qr overloading
It is now possible to overload the C<qr//> operator, that is,
conversion to regexp, like it was already possible to overload
conversion to boolean, string or number of objects. It is invoked when
an object appears on the right hand side of the C<=~> operator or when
it is interpolated into a regexp. See L<overload>.
=head2 Pluggable keywords
Extension modules can now cleanly hook into the Perl parser to define
new kinds of keyword-headed expression and compound statement. The
syntax following the keyword is defined entirely by the extension. This
allow a completely non-Perl sublanguage to be parsed inline, with the
correct ops cleanly generated.
See L<perlapi/PL_keyword_plugin> for the mechanism. The Perl core
source distribution also includes a new module
L<XS::APItest::KeywordRPN>, which implements reverse Polish notation
arithmetic via pluggable keywords. This module is mainly used for test
purposes, and is not normally installed, but also serves as an example
of how to use the new mechanism.
Perl's developers consider this feature to be experimental. We may remove
it or change it in a backwards-incompatible way in Perl 5.14.
=head2 APIs for more internals
The lowest layers of the lexer and parts of the pad system now have C
APIs available to XS extensions. These are necessary to support proper
use of pluggable keywords, but have other uses too. The new APIs are
experimental, and only cover a small proportion of what would be
necessary to take full advantage of the core's facilities in these
areas. It is intended that the Perl 5.13 development cycle will see the
addition of a full range of clean, supported interfaces.
Perl's developers consider this feature to be experimental. We may remove
it or change it in a backwards-incompatible way in Perl 5.14.
=head2 Overridable function lookup
Where an extension module hooks the creation of rv2cv ops to modify the
subroutine lookup process, this now works correctly for bareword
subroutine calls. This means that prototypes on subroutines referenced
this way will be processed correctly. (Previously bareword subroutine
names were initially looked up, for parsing purposes, by an unhookable
mechanism, so extensions could only properly influence subroutine names
that appeared with an C<&> sigil.)
=head2 A proper interface for pluggable Method Resolution Orders
As of Perl 5.12.0 there is a new interface for plugging and using method
resolution orders other than the default linear depth first search.
The C3 method resolution order added in 5.10.0 has been re-implemented as
a plugin, without changing its Perl-space interface. See L<perlmroapi> for
more information.
=head2 C<\N> experimental regex escape
Perl now supports C<\N>, a new regex escape which you can think of as
the inverse of C<\n>. It will match any character that is not a newline,
independently from the presence or absence of the single line match
modifier C</s>. It is not usable within a character class. C<\N{3}>
means to match 3 non-newlines; C<\N{5,}> means to match at least 5.
C<\N{NAME}> still means the character or sequence named C<NAME>, but
C<NAME> no longer can be things like C<3>, or C<5,>.
This will break a L<custom charnames translator|charnames/CUSTOM
TRANSLATORS> which allows numbers for character names, as C<\N{3}> will
now mean to match 3 non-newline characters, and not the character whose
name is C<3>. (No name defined by the Unicode standard is a number,
so only custom translators might be affected.)
Perl's developers are somewhat concerned about possible user confusion
with the existing C<\N{...}> construct which matches characters by their
Unicode name. Consequently, this feature is experimental. We may remove
it or change it in a backwards-incompatible way in Perl 5.14.
=head2 DTrace support
Perl now has some support for DTrace. See "DTrace support" in F<INSTALL>.
=head2 Support for C<configure_requires> in CPAN module metadata
Both C<CPAN> and C<CPANPLUS> now support the C<configure_requires>
keyword in the F<META.yml> metadata file included in most recent CPAN
distributions. This allows distribution authors to specify configuration
prerequisites that must be installed before running F<Makefile.PL>
or F<Build.PL>.
See the documentation for C<ExtUtils::MakeMaker> or C<Module::Build> for
more on how to specify C<configure_requires> when creating a distribution
for CPAN.
=head2 C<each> is now more flexible
The C<each> function can now operate on arrays.
=head2 C<when> as a statement modifier
C<when> is now allowed to be used as a statement modifier.
=head2 C<$,> flexibility
The variable C<$,> may now be tied.
=head2 // in when clauses
// now behaves like || in when clauses
=head2 Enabling warnings from your shell environment
You can now set C<-W> from the C<PERL5OPT> environment variable
=head2 C<delete local>
C<delete local> now allows you to locally delete a hash entry.
=head2 New support for Abstract namespace sockets
Abstract namespace sockets are Linux-specific socket type that live in
AF_UNIX family, slightly abusing it to be able to use arbitrary
character arrays as addresses: They start with nul byte and are not
terminated by nul byte, but with the length passed to the socket()
system call.
=head2 32-bit limit on substr arguments removed
The 32-bit limit on C<substr> arguments has now been removed. The full
range of the system's signed and unsigned integers is now available for
the C<pos> and C<len> arguments.
=head1 Potentially Incompatible Changes
=head2 Deprecations warn by default
Over the years, Perl's developers have deprecated a number of language
features for a variety of reasons. Perl now defaults to issuing a
warning if a deprecated language feature is used. Many of the deprecations
Perl now warns you about have been deprecated for many years. You can
find a list of what was deprecated in a given release of Perl in the
C<perl5xxdelta.pod> file for that release.
To disable this feature in a given lexical scope, you should use C<no
warnings 'deprecated';> For information about which language features
are deprecated and explanations of various deprecation warnings, please
see L<perldiag>. See L</Deprecations> below for the list of features
and modules Perl's developers have deprecated as part of this release.
=head2 Version number formats
Acceptable version number formats have been formalized into "strict" and
"lax" rules. C<package NAME VERSION> takes a strict version number.
C<UNIVERSAL::VERSION> and the L<version> object constructors take lax
version numbers. Providing an invalid version will result in a fatal
error. The version argument in C<use NAME VERSION> is first parsed as a
numeric literal or v-string and then passed to C<UNIVERSAL::VERSION>
(and must then pass the "lax" format test).
These formats are documented fully in the L<version> module. To a first
approximation, a "strict" version number is a positive decimal number
(integer or decimal-fraction) without exponentiation or else a
dotted-decimal v-string with a leading 'v' character and at least three
components. A "lax" version number allows v-strings with fewer than
three components or without a leading 'v'. Under "lax" rules, both
decimal and dotted-decimal versions may have a trailing "alpha"
component separated by an underscore character after a fractional or
dotted-decimal component.
The L<version> module adds C<version::is_strict> and C<version::is_lax>
functions to check a scalar against these rules.
=head2 @INC reorganization
In C<@INC>, C<ARCHLIB> and C<PRIVLIB> now occur after after the current
version's C<site_perl> and C<vendor_perl>. Modules installed into
C<site_perl> and C<vendor_perl> will now be loaded in preference to
those installed in C<ARCHLIB> and C<PRIVLIB>.
=head2 REGEXPs are now first class
Internally, Perl now treates compiled regular expressions (such as
those created with C<qr//>) as first class entities. Perl modules which
serialize, deserialize or otherwise have deep interaction with Perl's
internal data structures need to be updated for this change. Most
affected CPAN modules have already been updated as of this writing.
=head2 Switch statement changes
The C<given>/C<when> switch statement handles complex statements better
than Perl 5.10.0 did (These enhancements are also available in
5.10.1 and subsequent 5.10 releases.) There are two new cases where
C<when> now interprets its argument as a boolean, instead of an
expression to be used in a smart match:
=over
=item flip-flop operators
The C<..> and C<...> flip-flop operators are now evaluated in boolean
context, following their usual semantics; see L<perlop/"Range Operators">.
Note that, as in perl 5.10.0, C<when (1..10)> will not work to test
whether a given value is an integer between 1 and 10; you should use
C<when ([1..10])> instead (note the array reference).
However, contrary to 5.10.0, evaluating the flip-flop operators in
boolean context ensures it can now be useful in a C<when()>, notably
for implementing bistable conditions, like in:
when (/^=begin/ .. /^=end/) {
# do something
}
=item defined-or operator
A compound expression involving the defined-or operator, as in
C<when (expr1 // expr2)>, will be treated as boolean if the first
expression is boolean. (This just extends the existing rule that applies
to the regular or operator, as in C<when (expr1 || expr2)>.)
=back
=head2 Smart match changes
