📄 perldelta.pod
字号:
=head2 More generous treatment of carriage returns
Perl used to complain if it encountered literal carriage returns in
scripts. Now they are mostly treated like whitespace within program text.
Inside string literals and here documents, literal carriage returns are
ignored if they occur paired with newlines, or get interpreted as newlines
if they stand alone. This behavior means that literal carriage returns
in files should be avoided. You can get the older, more compatible (but
less generous) behavior by defining the preprocessor symbol
C<PERL_STRICT_CR> when building perl. Of course, all this has nothing
whatever to do with how escapes like C<\r> are handled within strings.
Note that this doesn't somehow magically allow you to keep all text files
in DOS format. The generous treatment only applies to files that perl
itself parses. If your C compiler doesn't allow carriage returns in
files, you may still be unable to build modules that need a C compiler.
=head2 Memory leaks
C<substr>, C<pos> and C<vec> don't leak memory anymore when used in lvalue
context. Many small leaks that impacted applications that embed multiple
interpreters have been fixed.
=head2 Better support for multiple interpreters
The build-time option C<-DMULTIPLICITY> has had many of the details
reworked. Some previously global variables that should have been
per-interpreter now are. With care, this allows interpreters to call
each other. See the C<PerlInterp> extension on CPAN.
=head2 Behavior of local() on array and hash elements is now well-defined
See L<perlsub/"Temporary Values via local()">.
=head2 C<%!> is transparently tied to the L<Errno> module
See L<perlvar>, and L<Errno>.
=head2 Pseudo-hashes are supported
See L<perlref>.
=head2 C<EXPR foreach EXPR> is supported
See L<perlsyn>.
=head2 Keywords can be globally overridden
See L<perlsub>.
=head2 C<$^E> is meaningful on Win32
See L<perlvar>.
=head2 C<foreach (1..1000000)> optimized
C<foreach (1..1000000)> is now optimized into a counting loop. It does
not try to allocate a 1000000-size list anymore.
=head2 C<Foo::> can be used as implicitly quoted package name
Barewords caused unintuitive behavior when a subroutine with the same
name as a package happened to be defined. Thus, C<new Foo @args>,
use the result of the call to C<Foo()> instead of C<Foo> being treated
as a literal. The recommended way to write barewords in the indirect
object slot is C<new Foo:: @args>. Note that the method C<new()> is
called with a first argument of C<Foo>, not C<Foo::> when you do that.
=head2 C<exists $Foo::{Bar::}> tests existence of a package
It was impossible to test for the existence of a package without
actually creating it before. Now C<exists $Foo::{Bar::}> can be
used to test if the C<Foo::Bar> namespace has been created.
=head2 Better locale support
See L<perllocale>.
=head2 Experimental support for 64-bit platforms
Perl5 has always had 64-bit support on systems with 64-bit longs.
Starting with 5.005, the beginnings of experimental support for systems
with 32-bit long and 64-bit 'long long' integers has been added.
If you add -DUSE_LONG_LONG to your ccflags in config.sh (or manually
define it in perl.h) then perl will be built with 'long long' support.
There will be many compiler warnings, and the resultant perl may not
work on all systems. There are many other issues related to
third-party extensions and libraries. This option exists to allow
people to work on those issues.
=head2 prototype() returns useful results on builtins
See L<perlfunc/prototype>.
=head2 Extended support for exception handling
C<die()> now accepts a reference value, and C<$@> gets set to that
value in exception traps. This makes it possible to propagate
exception objects. This is an undocumented B<experimental> feature.
=head2 Re-blessing in DESTROY() supported for chaining DESTROY() methods
See L<perlobj/Destructors>.
=head2 All C<printf> format conversions are handled internally
See L<perlfunc/printf>.
=head2 New C<INIT> keyword
C<INIT> subs are like C<BEGIN> and C<END>, but they get run just before
the perl runtime begins execution. e.g., the Perl Compiler makes use of
C<INIT> blocks to initialize and resolve pointers to XSUBs.
=head2 New C<lock> keyword
The C<lock> keyword is the fundamental synchronization primitive
in threaded perl. When threads are not enabled, it is currently a noop.
To minimize impact on source compatibility this keyword is "weak", i.e., any
user-defined subroutine of the same name overrides it, unless a C<use Thread>
has been seen.
=head2 New C<qr//> operator
The C<qr//> operator, which is syntactically similar to the other quote-like
operators, is used to create precompiled regular expressions. This compiled
form can now be explicitly passed around in variables, and interpolated in
other regular expressions. See L<perlop>.
=head2 C<our> is now a reserved word
Calling a subroutine with the name C<our> will now provoke a warning when
using the C<-w> switch.
=head2 Tied arrays are now fully supported
See L<Tie::Array>.
=head2 Tied handles support is better
Several missing hooks have been added. There is also a new base class for
TIEARRAY implementations. See L<Tie::Array>.
=head2 4th argument to substr
substr() can now both return and replace in one operation. The optional
4th argument is the replacement string. See L<perlfunc/substr>.
=head2 Negative LENGTH argument to splice
splice() with a negative LENGTH argument now work similar to what the
LENGTH did for substr(). Previously a negative LENGTH was treated as
0. See L<perlfunc/splice>.
=head2 Magic lvalues are now more magical
When you say something like C<substr($x, 5) = "hi">, the scalar returned
by substr() is special, in that any modifications to it affect $x.
(This is called a 'magic lvalue' because an 'lvalue' is something on
the left side of an assignment.) Normally, this is exactly what you
would expect to happen, but Perl uses the same magic if you use substr(),
pos(), or vec() in a context where they might be modified, like taking
a reference with C<\> or as an argument to a sub that modifies C<@_>.
In previous versions, this 'magic' only went one way, but now changes
to the scalar the magic refers to ($x in the above example) affect the
magic lvalue too. For instance, this code now acts differently:
$x = "hello";
sub printit {
$x = "g'bye";
print $_[0], "\n";
}
printit(substr($x, 0, 5));
In previous versions, this would print "hello", but it now prints "g'bye".
=head2 E<lt>E<gt> now reads in records
If C<$/> is a referenence to an integer, or a scalar that holds an integer,
E<lt>E<gt> will read in records instead of lines. For more info, see
L<perlvar/$/>.
=head1 Supported Platforms
Configure has many incremental improvements. Site-wide policy for building
perl can now be made persistent, via Policy.sh. Configure also records
the command-line arguments used in F<config.sh>.
=head2 New Platforms
BeOS is now supported. See L<README.beos>.
DOS is now supported under the DJGPP tools. See L<README.dos>.
MPE/iX is now supported. See L<README.mpeix>.
MVS (OS390) is now supported. See L<README.os390>.
=head2 Changes in existing support
Win32 support has been vastly enhanced. Support for Perl Object, a C++
encapsulation of Perl. GCC and EGCS are now supported on Win32.
See F<README.win32>, aka L<perlwin32>.
VMS configuration system has been rewritten. See L<README.vms>.
The hints files for most Unix platforms have seen incremental improvements.
=head1 Modules and Pragmata
=head2 New Modules
=over
=item B
Perl compiler and tools. See L<B>.
=item Data::Dumper
A module to pretty print Perl data. See L<Data::Dumper>.
=item Errno
A module to look up errors more conveniently. See L<Errno>.
=item File::Spec
A portable API for file operations.
=item ExtUtils::Installed
Query and manage installed modules.
=item ExtUtils::Packlist
Manipulate .packlist files.
=item Fatal
Make functions/builtins succeed or die.
=item IPC::SysV
Constants and other support infrastructure for System V IPC operations
in perl.
=item Test
A framework for writing testsuites.
=item Tie::Array
Base class for tied arrays.
=item Tie::Handle
Base class for tied handles.
=item Thread
Perl thread creation, manipulation, and support.
=item attrs
Set subroutine attributes.
=item fields
Compile-time class fields.
=item re
Various pragmata to control behavior of regular expressions.
=back
=head2 Changes in existing modules
=over
=item CGI
CGI has been updated to version 2.42.
=item POSIX
POSIX now has its own platform-specific hints files.
=item DB_File
DB_File supports version 2.x of Berkeley DB. See C<ext/DB_File/Changes>.
=item MakeMaker
MakeMaker now supports writing empty makefiles, provides a way to
specify that site umask() policy should be honored. There is also
better support for manipulation of .packlist files, and getting
information about installed modules.
Extensions that have both architecture-dependent and
architecture-independent files are now always installed completely in
the architecture-dependent locations. Previously, the shareable parts
were shared both across architectures and across perl versions and were
therefore liable to be overwritten with newer versions that might have
subtle incompatibilities.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -