perl56delta.1

来自「视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.」· 1 代码 · 共 1,468 行 · 第 1/5 页

1
1,468
字号
than v5.6.0 have been incrementing the subversion component in multiples of10.  Versions after v5.6.0 will increment them by 1.  Thus, using the newnotation, 5.005_03 is the \*(L"same\*(R" as v5.5.30, and the first maintenanceversion following v5.6.0 will be v5.6.1 (which should be read as beingequivalent to a floating point value of 5.006_001 in the older format,stored in \f(CW$]\fR)..Sh "New syntax for declaring subroutine attributes".IX Subsection "New syntax for declaring subroutine attributes"Formerly, if you wanted to mark a subroutine as being a method call oras requiring an automatic \fIlock()\fR when it is entered, you had to declarethat with a \f(CW\*(C`use attrs\*(C'\fR pragma in the body of the subroutine.That can now be accomplished with declaration syntax, like this:.PP.Vb 5\&    sub mymethod : locked method;\&    ...\&    sub mymethod : locked method {\&        ...\&    }\&\&    sub othermethod :locked :method;\&    ...\&    sub othermethod :locked :method {\&        ...\&    }.Ve.PP(Note how only the first \f(CW\*(C`:\*(C'\fR is mandatory, and whitespace surroundingthe \f(CW\*(C`:\*(C'\fR is optional.).PP\&\fIAutoSplit.pm\fR and \fISelfLoader.pm\fR have been updated to keep the attributeswith the stubs they provide.  See attributes..Sh "File and directory handles can be autovivified".IX Subsection "File and directory handles can be autovivified"Similar to how constructs such as \f(CW\*(C`$x\->[0]\*(C'\fR autovivify a reference,handle constructors (\fIopen()\fR, \fIopendir()\fR, \fIpipe()\fR, \fIsocketpair()\fR, \fIsysopen()\fR,\&\fIsocket()\fR, and \fIaccept()\fR) now autovivify a file or directory handleif the handle passed to them is an uninitialized scalar variable.  Thisallows the constructs such as \f(CW\*(C`open(my $fh, ...)\*(C'\fR and \f(CW\*(C`open(local $fh,...)\*(C'\fRto be used to create filehandles that will conveniently be closedautomatically when the scope ends, provided there are no other referencesto them.  This largely eliminates the need for typeglobs when openingfilehandles that must be passed around, as in the following example:.PP.Vb 5\&    sub myopen {\&        open my $fh, "@_"\&             or die "Can\*(Aqt open \*(Aq@_\*(Aq: $!";\&        return $fh;\&    }\&\&    {\&        my $f = myopen("</etc/motd");\&        print <$f>;\&        # $f implicitly closed here\&    }.Ve.Sh "\fIopen()\fP with more than two arguments".IX Subsection "open() with more than two arguments"If \fIopen()\fR is passed three arguments instead of two, the second argumentis used as the mode and the third argument is taken to be the file name.This is primarily useful for protecting against unintended magic behaviorof the traditional two-argument form.  See \*(L"open\*(R" in perlfunc..Sh "64\-bit support".IX Subsection "64-bit support"Any platform that has 64\-bit integers either.PP.Vb 3\&        (1) natively as longs or ints\&        (2) via special compiler flags\&        (3) using long long or int64_t.Ve.PPis able to use \*(L"quads\*(R" (64\-bit integers) as follows:.IP "\(bu" 4constants (decimal, hexadecimal, octal, binary) in the code.IP "\(bu" 4arguments to \fIoct()\fR and \fIhex()\fR.IP "\(bu" 4arguments to \fIprint()\fR, \fIprintf()\fR and \fIsprintf()\fR (flag prefixes ll, L, q).IP "\(bu" 4printed as such.IP "\(bu" 4\&\fIpack()\fR and \fIunpack()\fR \*(L"q\*(R" and \*(L"Q\*(R" formats.IP "\(bu" 4in basic arithmetics: + \- * / % (\s-1NOTE:\s0 operating close to the limitsof the integer values may produce surprising results).IP "\(bu" 4in bit arithmetics: & | ^ ~ << >> (\s-1NOTE:\s0 these used to be forced to be 32 bits wide but now operate on the full native width.).IP "\(bu" 4\&\fIvec()\fR.PPNote that unless you have the case (a) you will have to configureand compile Perl using the \-Duse64bitint Configure flag..PP.Vb 2\&    NOTE: The Configure flags \-Duselonglong and \-Duse64bits have been\&    deprecated.  Use \-Duse64bitint instead..Ve.PPThere are actually two modes of 64\-bitness: the first one is achievedusing Configure \-Duse64bitint and the second one using Configure\&\-Duse64bitall.  The difference is that the first one is minimal andthe second one maximal.  The first works in more places than the second..PPThe \f(CW\*(C`use64bitint\*(C'\fR does only as much as is required to get 64\-bitintegers into Perl (this may mean, for example, using \*(L"long longs\*(R")while your memory may still be limited to 2 gigabytes (because yourpointers could still be 32\-bit).  Note that the name \f(CW\*(C`64bitint\*(C'\fR doesnot imply that your C compiler will be using 64\-bit \f(CW\*(C`int\*(C'\fRs (it might,but it doesn't have to): the \f(CW\*(C`use64bitint\*(C'\fR means that you will beable to have 64 bits wide scalar values..PPThe \f(CW\*(C`use64bitall\*(C'\fR goes all the way by attempting to switch alsointegers (if it can), longs (and pointers) to being 64\-bit.  This maycreate an even more binary incompatible Perl than \-Duse64bitint: theresulting executable may not run at all in a 32\-bit box, or you mayhave to reboot/reconfigure/rebuild your operating system to be 64\-bitaware..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

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?