📄 perl5100delta.1
字号:
it's possible to do something like.Sp.Vb 3\& foreach my $name (keys %+) {\& print "content of buffer \*(Aq$name\*(Aq is $+{$name}\en";\& }.Ve.SpThe \f(CW\*(C`%\-\*(C'\fR hash is a bit more complete, since it will contain array refsholding values from all capture buffers similarly named, if there shouldbe many of them..Sp\&\f(CW\*(C`%+\*(C'\fR and \f(CW\*(C`%\-\*(C'\fR are implemented as tied hashes through the new module\&\f(CW\*(C`Tie::Hash::NamedCapture\*(C'\fR..SpUsers exposed to the .NET regex engine will find that the perlimplementation differs in that the numerical ordering of the buffersis sequential, and not \*(L"unnamed first, then named\*(R". Thus in the pattern.Sp.Vb 1\& /(A)(?<B>B)(C)(?<D>D)/.Ve.Sp\&\f(CW$1\fR will be 'A', \f(CW$2\fR will be 'B', \f(CW$3\fR will be 'C' and \f(CW$4\fR will be 'D' and not\&\f(CW$1\fR is 'A', \f(CW$2\fR is 'C' and \f(CW$3\fR is 'B' and \f(CW$4\fR is 'D' that a .NET programmerwould expect. This is considered a feature. :\-) (Yves Orton).IP "Possessive Quantifiers" 4.IX Item "Possessive Quantifiers"Perl now supports the \*(L"possessive quantifier\*(R" syntax of the \*(L"atomic match\*(R"pattern. Basically a possessive quantifier matches as much as it can and nevergives any back. Thus it can be used to control backtracking. The syntax issimilar to non-greedy matching, except instead of using a '?' as the modifierthe '+' is used. Thus \f(CW\*(C`?+\*(C'\fR, \f(CW\*(C`*+\*(C'\fR, \f(CW\*(C`++\*(C'\fR, \f(CW\*(C`{min,max}+\*(C'\fR are now legalquantifiers. (Yves Orton).IP "Backtracking control verbs" 4.IX Item "Backtracking control verbs"The regex engine now supports a number of special-purpose backtrackcontrol verbs: (*THEN), (*PRUNE), (*MARK), (*SKIP), (*COMMIT), (*FAIL)and (*ACCEPT). See perlre for their descriptions. (Yves Orton).IP "Relative backreferences" 4.IX Item "Relative backreferences"A new syntax \f(CW\*(C`\eg{N}\*(C'\fR or \f(CW\*(C`\egN\*(C'\fR where \*(L"N\*(R" is a decimal integer allows asafer form of back-reference notation as well as allowing relativebackreferences. This should make it easier to generate and embed patternsthat contain backreferences. See \*(L"Capture buffers\*(R" in perlre. (Yves Orton).ie n .IP """\eK"" escape" 4.el .IP "\f(CW\eK\fR escape" 4.IX Item "K escape"The functionality of Jeff Pinyan's module Regexp::Keep has been added tothe core. In regular expressions you can now use the special escape \f(CW\*(C`\eK\*(C'\fRas a way to do something like floating length positive lookbehind. It isalso useful in substitutions like:.Sp.Vb 1\& s/(foo)bar/$1/g.Ve.Spthat can now be converted to.Sp.Vb 1\& s/foo\eKbar//g.Ve.Spwhich is much more efficient. (Yves Orton).IP "Vertical and horizontal whitespace, and linebreak" 4.IX Item "Vertical and horizontal whitespace, and linebreak"Regular expressions now recognize the \f(CW\*(C`\ev\*(C'\fR and \f(CW\*(C`\eh\*(C'\fR escapes that matchvertical and horizontal whitespace, respectively. \f(CW\*(C`\eV\*(C'\fR and \f(CW\*(C`\eH\*(C'\fRlogically match their complements..Sp\&\f(CW\*(C`\eR\*(C'\fR matches a generic linebreak, that is, vertical whitespace, plusthe multi-character sequence \f(CW"\ex0D\ex0A"\fR..ie n .Sh """say()""".el .Sh "\f(CWsay()\fP".IX Subsection "say()"\&\fIsay()\fR is a new built-in, only available when \f(CW\*(C`use feature \*(Aqsay\*(Aq\*(C'\fR is ineffect, that is similar to \fIprint()\fR, but that implicitly appends a newlineto the printed string. See \*(L"say\*(R" in perlfunc. (Robin Houston).ie n .Sh "Lexical $_".el .Sh "Lexical \f(CW$_\fP".IX Subsection "Lexical $_"The default variable \f(CW$_\fR can now be lexicalized, by declaring it likeany other lexical variable, with a simple.PP.Vb 1\& my $_;.Ve.PPThe operations that default on \f(CW$_\fR will use the lexically-scopedversion of \f(CW$_\fR when it exists, instead of the global \f(CW$_\fR..PPIn a \f(CW\*(C`map\*(C'\fR or a \f(CW\*(C`grep\*(C'\fR block, if \f(CW$_\fR was previously my'ed, then the\&\f(CW$_\fR inside the block is lexical as well (and scoped to the block)..PPIn a scope where \f(CW$_\fR has been lexicalized, you can still have access tothe global version of \f(CW$_\fR by using \f(CW$::_\fR, or, more simply, byoverriding the lexical declaration with \f(CW\*(C`our $_\*(C'\fR. (Rafael Garcia-Suarez).ie n .Sh "The ""_"" prototype".el .Sh "The \f(CW_\fP prototype".IX Subsection "The _ prototype"A new prototype character has been added. \f(CW\*(C`_\*(C'\fR is equivalent to \f(CW\*(C`$\*(C'\fR butdefaults to \f(CW$_\fR if the corresponding argument isn't supplied. (both \f(CW\*(C`$\*(C'\fRand \f(CW\*(C`_\*(C'\fR denote a scalar). Due to the optional nature of the argument, youcan only use it at the end of a prototype, or before a semicolon..PPThis has a small incompatible consequence: the \fIprototype()\fR function hasbeen adjusted to return \f(CW\*(C`_\*(C'\fR for some built-ins in appropriate cases (forexample, \f(CW\*(C`prototype(\*(AqCORE::rmdir\*(Aq)\*(C'\fR). (Rafael Garcia-Suarez).Sh "\s-1UNITCHECK\s0 blocks".IX Subsection "UNITCHECK blocks"\&\f(CW\*(C`UNITCHECK\*(C'\fR, a new special code block has been introduced, in addition to\&\f(CW\*(C`BEGIN\*(C'\fR, \f(CW\*(C`CHECK\*(C'\fR, \f(CW\*(C`INIT\*(C'\fR and \f(CW\*(C`END\*(C'\fR..PP\&\f(CW\*(C`CHECK\*(C'\fR and \f(CW\*(C`INIT\*(C'\fR blocks, while useful for some specialized purposes,are always executed at the transition between the compilation and theexecution of the main program, and thus are useless whenever code isloaded at runtime. On the other hand, \f(CW\*(C`UNITCHECK\*(C'\fR blocks are executedjust after the unit which defined them has been compiled. See perlmodfor more information. (Alex Gough).ie n .Sh "New Pragma, ""mro""".el .Sh "New Pragma, \f(CWmro\fP".IX Subsection "New Pragma, mro"A new pragma, \f(CW\*(C`mro\*(C'\fR (for Method Resolution Order) has been added. Itpermits to switch, on a per-class basis, the algorithm that perl uses tofind inherited methods in case of a multiple inheritance hierarchy. Thedefault \s-1MRO\s0 hasn't changed (\s-1DFS\s0, for Depth First Search). Another \s-1MRO\s0 isavailable: the C3 algorithm. See mro for more information.(Brandon Black).PPNote that, due to changes in the implementation of class hierarchy search,code that used to undef the \f(CW*ISA\fR glob will most probably break. Anyway,undef'ing \f(CW*ISA\fR had the side-effect of removing the magic on the \f(CW@ISA\fRarray and should not have been done in the first place. Also, thecache \f(CW*::ISA::CACHE::\fR no longer exists; to force reset the \f(CW@ISA\fR cache,you now need to use the \f(CW\*(C`mro\*(C'\fR \s-1API\s0, or more simply to assign to \f(CW@ISA\fR(e.g. with \f(CW\*(C`@ISA = @ISA\*(C'\fR)..ie n .Sh "\fIreaddir()\fP may return a ""short filename"" on Windows".el .Sh "\fIreaddir()\fP may return a ``short filename'' on Windows".IX Subsection "readdir() may return a short filename on Windows"The \fIreaddir()\fR function may return a \*(L"short filename\*(R" when the longfilename contains characters outside the \s-1ANSI\s0 codepage. Similarly\&\fICwd::cwd()\fR may return a short directory name, and \fIglob()\fR may return shortnames as well. On the \s-1NTFS\s0 file system these short names can always berepresented in the \s-1ANSI\s0 codepage. This will not be true for all other filesystem drivers; e.g. the \s-1FAT\s0 filesystem stores short filenames in the \s-1OEM\s0codepage, so some files on \s-1FAT\s0 volumes remain unaccessible through the\&\s-1ANSI\s0 APIs..PPSimilarly, $^X, \f(CW@INC\fR, and \f(CW$ENV\fR{\s-1PATH\s0} are preprocessed at startup to makesure all paths are valid in the \s-1ANSI\s0 codepage (if possible)..PPThe \fIWin32::GetLongPathName()\fR function now returns the \s-1UTF\-8\s0 encodedcorrect long file name instead of using replacement characters to forcethe name into the \s-1ANSI\s0 codepage. The new \fIWin32::GetANSIPathName()\fRfunction can be used to turn a long pathname into a short one only if thelong one cannot be represented in the \s-1ANSI\s0 codepage..PPMany other functions in the \f(CW\*(C`Win32\*(C'\fR module have been improved to accept\&\s-1UTF\-8\s0 encoded arguments. Please see Win32 for details..Sh "\fIreadpipe()\fP is now overridable".IX Subsection "readpipe() is now overridable"The built-in function \fIreadpipe()\fR is now overridable. Overriding it permitsalso to override its operator counterpart, \f(CW\*(C`qx//\*(C'\fR (a.k.a. \f(CW\*(C`\`\`\*(C'\fR).Moreover, it now defaults to \f(CW$_\fR if no argument is provided. (RafaelGarcia-Suarez).Sh "Default argument for \fIreadline()\fP".IX Subsection "Default argument for readline()"\&\fIreadline()\fR now defaults to \f(CW*ARGV\fR if no argument is provided. (RafaelGarcia-Suarez).Sh "\fIstate()\fP variables".IX Subsection "state() variables"A new class of variables has been introduced. State variables are similarto \f(CW\*(C`my\*(C'\fR variables, but are declared with the \f(CW\*(C`state\*(C'\fR keyword in place of\&\f(CW\*(C`my\*(C'\fR. They're visible only in their lexical scope, but their value ispersistent: unlike \f(CW\*(C`my\*(C'\fR variables, they're not undefined at scope entry,but retain their previous value. (Rafael Garcia-Suarez, Nicholas Clark).PPTo use state variables, one needs to enable them by using.PP.Vb 1\& use feature \*(Aqstate\*(Aq;.Ve.PPor by using the \f(CW\*(C`\-E\*(C'\fR command-line switch in one-liners.See \*(L"Persistent variables via \fIstate()\fR\*(R" in perlsub..Sh "Stacked filetest operators".IX Subsection "Stacked filetest operators"As a new form of syntactic sugar, it's now possible to stack up filetestoperators. You can now write \f(CW\*(C`\-f \-w \-x $file\*(C'\fR in a row to mean\&\f(CW\*(C`\-x $file && \-w _ && \-f _\*(C'\fR. See \*(L"\-X\*(R" in perlfunc..Sh "\s-1\fIUNIVERSAL::DOES\s0()\fP".IX Subsection "UNIVERSAL::DOES()"The \f(CW\*(C`UNIVERSAL\*(C'\fR class has a new method, \f(CW\*(C`DOES()\*(C'\fR. It has been added tosolve semantic problems with the \f(CW\*(C`isa()\*(C'\fR method. \f(CW\*(C`isa()\*(C'\fR checks forinheritance, while \f(CW\*(C`DOES()\*(C'\fR has been designed to be overridden whenmodule authors use other types of relations between classes (in additionto inheritance). (chromatic).PPSee \*(L"$obj\->\s-1DOES\s0( \s-1ROLE\s0 )\*(R" in \s-1UNIVERSAL\s0..Sh "Formats".IX Subsection "Formats"Formats were improved in several ways. A new field, \f(CW\*(C`^*\*(C'\fR, can be used forvariable-width, one-line-at-a-time text. Null characters are now handledcorrectly in picture lines. Using \f(CW\*(C`@#\*(C'\fR and \f(CW\*(C`~~\*(C'\fR together will nowproduce a compile-time error, as those format fields are incompatible.perlform has been improved, and miscellaneous bugs fixed..Sh "Byte-order modifiers for \fIpack()\fP and \fIunpack()\fP".IX Subsection "Byte-order modifiers for pack() and unpack()"There are two new byte-order modifiers, \f(CW\*(C`>\*(C'\fR (big-endian) and \f(CW\*(C`<\*(C'\fR(little-endian), that can be appended to most \fIpack()\fR and \fIunpack()\fR templatecharacters and groups to force a certain byte-order for that type or group.See \*(L"pack\*(R" in perlfunc and perlpacktut for details..ie n .Sh """no VERSION""".el .Sh "\f(CWno VERSION\fP".IX Subsection "no VERSION"You can now use \f(CW\*(C`no\*(C'\fR followed by a version number to specify that youwant to use a version of perl older than the specified one..ie n .Sh """chdir""\fP, \f(CW""chmod""\fP and \f(CW""chown"" on filehandles".el .Sh "\f(CWchdir\fP, \f(CWchmod\fP and \f(CWchown\fP on filehandles".IX Subsection "chdir, chmod and chown on filehandles"\&\f(CW\*(C`chdir\*(C'\fR, \f(CW\*(C`chmod\*(C'\fR and \f(CW\*(C`chown\*(C'\fR can now work on filehandles as well asfilenames, if the system supports respectively \f(CW\*(C`fchdir\*(C'\fR, \f(CW\*(C`fchmod\*(C'\fR and\&\f(CW\*(C`fchown\*(C'\fR, thanks to a patch provided by Gisle Aas..Sh "\s-1OS\s0 groups".IX Subsection "OS groups"\&\f(CW$(\fR and \f(CW$)\fR now return groups in the order where the \s-1OS\s0 returns them,thanks to Gisle Aas. This wasn't previously the case..Sh "Recursive sort subs".IX Subsection "Recursive sort subs"You can now use recursive subroutines with \fIsort()\fR, thanks to Robin Houston..Sh "Exceptions in constant folding".IX Subsection "Exceptions in constant folding"The constant folding routine is now wrapped in an exception handler, andif folding throws an exception (such as attempting to evaluate 0/0), perlnow retains the current optree, rather than aborting the whole program.Without this change, programs would not compile if they had expressions thathappened to generate exceptions, even though those expressions were in codethat could never be reached at runtime. (Nicholas Clark, Dave Mitchell).ie n .Sh "Source filters in @INC".el .Sh "Source filters in \f(CW@INC\fP".IX Subsection "Source filters in @INC"It's possible to enhance the mechanism of subroutine hooks in \f(CW@INC\fR byadding a source filter on top of the filehandle opened and returned by thehook. This feature was planned a long time ago, but wasn't quite workinguntil now. See \*(L"require\*(R" in perlfunc for details. (Nicholas Clark).Sh "New internal variables".IX Subsection "New internal variables".ie n .IP """${^RE_DEBUG_FLAGS}""" 4.el .IP "\f(CW${^RE_DEBUG_FLAGS}\fR" 4.IX Item "${^RE_DEBUG_FLAGS}"This variable controls what debug flags are in effect for the regularexpression engine when running under \f(CW\*(C`use re "debug"\*(C'\fR. See re fordetails..ie n .IP """${^CHILD_ERROR_NATIVE}""" 4.el .IP "\f(CW${^CHILD_ERROR_NATIVE}\fR" 4.IX Item "${^CHILD_ERROR_NATIVE}"This variable gives the native status returned by the last pipe close,backtick command, successful call to \fIwait()\fR or \fIwaitpid()\fR, or from the\&\fIsystem()\fR operator. See perlrun for details. (Contributed by Gisle Aas.).ie n .IP """${^RE_TRIE_MAXBUF}""" 4.el .IP "\f(CW${^RE_TRIE_MAXBUF}\fR" 4.IX Item "${^RE_TRIE_MAXBUF}"See \*(L"Trie optimisation of literal string alternations\*(R"..ie n .IP """${^WIN32_SLOPPY_STAT}""" 4.el .IP "\f(CW${^WIN32_SLOPPY_STAT}\fR" 4.IX Item "${^WIN32_SLOPPY_STAT}"See \*(L"Sloppy stat on Windows\*(R"..Sh "Miscellaneous".IX Subsection "Miscellaneous"\&\f(CW\*(C`unpack()\*(C'\fR now defaults to unpacking the \f(CW$_\fR variable..PP\&\f(CW\*(C`mkdir()\*(C'\fR without arguments now defaults to \f(CW$_\fR..PPThe internal dump output has been improved, so that non-printable characterssuch as newline and backspace are output in \f(CW\*(C`\ex\*(C'\fR notation, rather than
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -