📄 perl561delta.1
字号:
aware..PPNatively 64\-bit systems like Alpha and Cray need neither \-Duse64bitintnor \-Duse64bitall..PPLast but not least: note that due to Perl's habit of always usingfloating point numbers, the quads are still not true integers.When quads overflow their limits (0...18_446_744_073_709_551_615 unsigned,\&\-9_223_372_036_854_775_808...9_223_372_036_854_775_807 signed), theyare silently promoted to floating point numbers, after which they willstart losing precision (in their lower digits)..PP.Vb 4\& NOTE: 64\-bit support is still experimental on most platforms.\& Existing support only covers the LP64 data model. In particular, the\& LLP64 data model is not yet supported. 64\-bit libraries and system\& APIs on many platforms have not stabilized\-\-your mileage may vary..Ve.Sh "Large file support".IX Subsection "Large file support"If you have filesystems that support \*(L"large files\*(R" (files larger than2 gigabytes), you may now also be able to create and access them fromPerl..PP.Vb 2\& NOTE: The default action is to enable large file support, if\& available on the platform..Ve.PPIf the large file support is on, and you have a Fcntl constantO_LARGEFILE, the O_LARGEFILE is automatically added to the flagsof \fIsysopen()\fR..PPBeware that unless your filesystem also supports \*(L"sparse files\*(R" seekingto umpteen petabytes may be inadvisable..PPNote that in addition to requiring a proper file system to do largefiles you may also need to adjust your per-process (or yourper-system, or per-process-group, or per-user-group) maximum filesizelimits before running Perl scripts that try to handle large files,especially if you intend to write such files..PPFinally, in addition to your process/process group maximum filesizelimits, you may have quota limits on your filesystems that stop you(your user id or your user group id) from using large files..PPAdjusting your process/user/group/file system/operating system limitsis outside the scope of Perl core language. For process limits, youmay try increasing the limits using your shell's limits/limit/ulimitcommand before running Perl. The BSD::Resource extension (notincluded with the standard Perl distribution) may also be of use, itoffers the getrlimit/setrlimit interface that can be used to adjustprocess resource usage limits, including the maximum filesize limit..Sh "Long doubles".IX Subsection "Long doubles"In some systems you may be able to use long doubles to enhance therange and precision of your double precision floating point numbers(that is, Perl's numbers). Use Configure \-Duselongdouble to enablethis support (if it is available)..ie n .Sh """more bits""".el .Sh "``more bits''".IX Subsection "more bits"You can \*(L"Configure \-Dusemorebits\*(R" to turn on both the 64\-bit supportand the long double support..Sh "Enhanced support for \fIsort()\fP subroutines".IX Subsection "Enhanced support for sort() subroutines"Perl subroutines with a prototype of \f(CW\*(C`($$)\*(C'\fR, and XSUBs in general, cannow be used as sort subroutines. In either case, the two elements tobe compared are passed as normal parameters in \f(CW@_\fR. See \*(L"sort\*(R" in perlfunc..PPFor unprototyped sort subroutines, the historical behavior of passing the elements to be compared as the global variables \f(CW$a\fR and \f(CW$b\fR remainsunchanged..ie n .Sh """sort $coderef @foo"" allowed".el .Sh "\f(CWsort $coderef @foo\fP allowed".IX Subsection "sort $coderef @foo allowed"\&\fIsort()\fR did not accept a subroutine reference as the comparisonfunction in earlier versions. This is now permitted..Sh "File globbing implemented internally".IX Subsection "File globbing implemented internally"Perl now uses the File::Glob implementation of the \fIglob()\fR operatorautomatically. This avoids using an external csh process and theproblems associated with it..PP.Vb 2\& NOTE: This is currently an experimental feature. Interfaces and\& implementation are subject to change..Ve.Sh "Support for \s-1CHECK\s0 blocks".IX Subsection "Support for CHECK blocks"In addition to \f(CW\*(C`BEGIN\*(C'\fR, \f(CW\*(C`INIT\*(C'\fR, \f(CW\*(C`END\*(C'\fR, \f(CW\*(C`DESTROY\*(C'\fR and \f(CW\*(C`AUTOLOAD\*(C'\fR,subroutines named \f(CW\*(C`CHECK\*(C'\fR are now special. These are queued up duringcompilation and behave similar to \s-1END\s0 blocks, except they are called atthe end of compilation rather than at the end of execution. They cannotbe called directly..Sh "\s-1POSIX\s0 character class syntax [: :] supported".IX Subsection "POSIX character class syntax [: :] supported"For example to match alphabetic characters use /[[:alpha:]]/.See perlre for details..Sh "Better pseudo-random number generator".IX Subsection "Better pseudo-random number generator"In 5.005_0x and earlier, perl's \fIrand()\fR function used the C library\&\fIrand\fR\|(3) function. As of 5.005_52, Configure tests for \fIdrand48()\fR,\&\fIrandom()\fR, and \fIrand()\fR (in that order) and picks the first one it finds..PPThese changes should result in better random numbers from \fIrand()\fR..ie n .Sh "Improved ""qw//"" operator".el .Sh "Improved \f(CWqw//\fP operator".IX Subsection "Improved qw// operator"The \f(CW\*(C`qw//\*(C'\fR operator is now evaluated at compile time into a true listinstead of being replaced with a run time call to \f(CW\*(C`split()\*(C'\fR. Thisremoves the confusing misbehaviour of \f(CW\*(C`qw//\*(C'\fR in scalar context, whichhad inherited that behaviour from \fIsplit()\fR..PPThus:.PP.Vb 1\& $foo = ($bar) = qw(a b c); print "$foo|$bar\en";.Ve.PPnow correctly prints \*(L"3|a\*(R", instead of \*(L"2|a\*(R"..Sh "Better worst-case behavior of hashes".IX Subsection "Better worst-case behavior of hashes"Small changes in the hashing algorithm have been implemented inorder to improve the distribution of lower order bits in thehashed value. This is expected to yield better performance onkeys that are repeated sequences..Sh "\fIpack()\fP format 'Z' supported".IX Subsection "pack() format 'Z' supported"The new format type 'Z' is useful for packing and unpacking null-terminatedstrings. See \*(L"pack\*(R" in perlfunc..Sh "\fIpack()\fP format modifier '!' supported".IX Subsection "pack() format modifier '!' supported"The new format type modifier '!' is useful for packing and unpackingnative shorts, ints, and longs. See \*(L"pack\*(R" in perlfunc..Sh "\fIpack()\fP and \fIunpack()\fP support counted strings".IX Subsection "pack() and unpack() support counted strings"The template character '/' can be used to specify a counted stringtype to be packed or unpacked. See \*(L"pack\*(R" in perlfunc..Sh "Comments in \fIpack()\fP templates".IX Subsection "Comments in pack() templates"The '#' character in a template introduces a comment up toend of the line. This facilitates documentation of \fIpack()\fRtemplates..Sh "Weak references".IX Subsection "Weak references"In previous versions of Perl, you couldn't cache objects so asto allow them to be deleted if the last reference from outside the cache is deleted. The reference in the cache would hold areference count on the object and the objects would never bedestroyed..PPAnother familiar problem is with circular references. When anobject references itself, its reference count would never godown to zero, and it would not get destroyed until the programis about to exit..PPWeak references solve this by allowing you to \*(L"weaken\*(R" anyreference, that is, make it not count towards the reference count.When the last non-weak reference to an object is deleted, the objectis destroyed and all the weak references to the object areautomatically undef-ed..PPTo use this feature, you need the Devel::WeakRef package from \s-1CPAN\s0, whichcontains additional documentation..PP.Vb 1\& NOTE: This is an experimental feature. Details are subject to change..Ve.Sh "Binary numbers supported".IX Subsection "Binary numbers supported"Binary numbers are now supported as literals, in s?printf formats, and\&\f(CW\*(C`oct()\*(C'\fR:.PP.Vb 2\& $answer = 0b101010;\& printf "The answer is: %b\en", oct("0b101010");.Ve.Sh "Lvalue subroutines".IX Subsection "Lvalue subroutines"Subroutines can now return modifiable lvalues.See \*(L"Lvalue subroutines\*(R" in perlsub..PP.Vb 1\& NOTE: This is an experimental feature. Details are subject to change..Ve.Sh "Some arrows may be omitted in calls through references".IX Subsection "Some arrows may be omitted in calls through references"Perl now allows the arrow to be omitted in many constructsinvolving subroutine calls through references. For example,\&\f(CW\*(C`$foo[10]\->(\*(Aqfoo\*(Aq)\*(C'\fR may now be written \f(CW\*(C`$foo[10](\*(Aqfoo\*(Aq)\*(C'\fR.This is rather similar to how the arrow may be omitted from\&\f(CW\*(C`$foo[10]\->{\*(Aqfoo\*(Aq}\*(C'\fR. Note however, that the arrow is stillrequired for \f(CW\*(C`foo(10)\->(\*(Aqbar\*(Aq)\*(C'\fR..Sh "Boolean assignment operators are legal lvalues".IX Subsection "Boolean assignment operators are legal lvalues"Constructs such as \f(CW\*(C`($a ||= 2) += 1\*(C'\fR are now allowed..Sh "\fIexists()\fP is supported on subroutine names".IX Subsection "exists() is supported on subroutine names"The \fIexists()\fR builtin now works on subroutine names. A subroutineis considered to exist if it has been declared (even if implicitly).See \*(L"exists\*(R" in perlfunc for examples..Sh "\fIexists()\fP and \fIdelete()\fP are supported on array elements".IX Subsection "exists() and delete() are supported on array elements"The \fIexists()\fR and \fIdelete()\fR builtins now work on simple arrays as well.The behavior is similar to that on hash elements..PP\&\fIexists()\fR can be used to check whether an array element has beeninitialized. This avoids autovivifying array elements that don't exist.If the array is tied, the \s-1\fIEXISTS\s0()\fR method in the corresponding tiedpackage will be invoked..PP\&\fIdelete()\fR may be used to remove an element from the array and returnit. The array element at that position returns to its uninitializedstate, so that testing for the same element with \fIexists()\fR will returnfalse. If the element happens to be the one at the end, the size ofthe array also shrinks up to the highest element that tests true for\&\fIexists()\fR, or 0 if none such is found. If the array is tied, the \s-1\fIDELETE\s0()\fR method in the corresponding tied package will be invoked..PPSee \*(L"exists\*(R" in perlfunc and \*(L"delete\*(R" in perlfunc for examples..Sh "Pseudo-hashes work better".IX Subsection "Pseudo-hashes work better"Dereferencing some types of reference values in a pseudo-hash,such as \f(CW\*(C`$ph\->{foo}[1]\*(C'\fR, was accidentally disallowed. This hasbeen corrected..PPWhen applied to a pseudo-hash element, \fIexists()\fR now reports whetherthe specified value exists, not merely if the key is valid..PP\&\fIdelete()\fR now works on pseudo-hashes. When given a pseudo-hash elementor slice it deletes the values corresponding to the keys (but not the keysthemselves). See \*(L"Pseudo-hashes: Using an array as a hash\*(R" in perlref..PPPseudo-hash slices with constant keys are now optimized to array lookupsat compile-time..PPList assignments to pseudo-hash slices are now supported..PPThe \f(CW\*(C`fields\*(C'\fR pragma now provides ways to create pseudo-hashes, via\&\fIfields::new()\fR and \fIfields::phash()\fR. See fields..PP.Vb 3\& NOTE: The pseudo\-hash data type continues to be experimental.\& Limiting oneself to the interface elements provided by the\& fields pragma will provide protection from any future changes..Ve.Sh "Automatic flushing of output buffers".IX Subsection "Automatic flushing of output buffers"\&\fIfork()\fR, \fIexec()\fR, \fIsystem()\fR, qx//, and pipe \fIopen()\fRs now flush buffersof all files opened for output when the operation was attempted. Thismostly eliminates confusing buffering mishaps suffered by users unawareof how Perl internally handles I/O..PPThis is not supported on some platforms like Solaris where a suitablycorrect implementation of fflush(\s-1NULL\s0) isn't available..Sh "Better diagnostics on meaningless filehandle operations".IX Subsection "Better diagnostics on meaningless filehandle operations"Constructs such as \f(CW\*(C`open(<FH>)\*(C'\fR and \f(CW\*(C`close(<FH>)\*(C'\fRare compile time errors. Attempting to read from filehandles thatwere opened only for writing will now produce warnings (just aswriting to read-only filehandles does)..Sh "Where possible, buffered data discarded from duped input filehandle".IX Subsection "Where possible, buffered data discarded from duped input filehandle"\&\f(CW\*(C`open(NEW, "<&OLD")\*(C'\fR now attempts to discard any data thatwas previously read and buffered in \f(CW\*(C`OLD\*(C'\fR before duping the handle.On platforms where doing this is allowed, the next read operationon \f(CW\*(C`NEW\*(C'\fR will return the same data as the corresponding operationon \f(CW\*(C`OLD\*(C'\fR. Formerly, it would have returned the data from the startof the following disk block instead..Sh "\fIeof()\fP has the same old magic as <>".IX Subsection "eof() has the same old magic as <>"\&\f(CW\*(C`eof()\*(C'\fR would return true if no attempt to read from \f(CW\*(C`<>\*(C'\fR hadyet been made. \f(CW\*(C`eof()\*(C'\fR has been changed to have a little magic of itsown, it now opens the \f(CW\*(C`<>\*(C'\fR files..Sh "\fIbinmode()\fP can be used to set :crlf and :raw modes".IX Subsection "binmode() can be used to set :crlf and :raw modes"\&\fIbinmode()\fR now accepts a second argument that specifies a disciplinefor the handle in question. The two pseudo-disciplines \*(L":raw\*(R" and\&\*(L":crlf\*(R" are currently supported on DOS-derivative platforms.See \*(L"binmode\*(R" in perlfunc and open..ie n .Sh """\-T"" filetest recognizes \s-1UTF\-8\s0 encoded files as ""text""".el .Sh "\f(CW\-T\fP filetest recognizes \s-1UTF\-8\s0 encoded files as ``text''".IX Subsection "-T filetest recognizes UTF-8 encoded files as text"The algorithm used for the \f(CW\*(C`\-T\*(C'\fR filetest has been enhanced tocorrectly identify \s-1UTF\-8\s0 content as \*(L"text\*(R"..Sh "\fIsystem()\fP, backticks and pipe open now reflect \fIexec()\fP failure".IX Subsection "system(), backticks and pipe open now reflect exec() failure"On Unix and similar platforms, \fIsystem()\fR, \fIqx()\fR and open(\s-1FOO\s0, \*(L"cmd |\*(R")etc., are implemented via \fIfork()\fR and \fIexec()\fR. When the underlying\&\fIexec()\fR fails, earlier versions did not report the error properly,since the \fIexec()\fR happened to be in a different process..PPThe child process now communicates with the parent about theerror in launching the external command, which allows theseconstructs to return with their usual error value and set $!..Sh "Improved diagnostics".IX Subsection "Improved diagnostics"Line numbers are no longer suppressed (under most likely circumstances)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -