📄 perl58delta.1
字号:
This warns you that \f(CW"fred@example.com"\fR is going to turn into\&\f(CW\*(C`fred.com\*(C'\fR if you don't backslash the \f(CW\*(C`@\*(C'\fR.See http://www.plover.com/~mjd/perl/at\-error.html for more detailsabout the history here..Sh "Miscellaneous Changes".IX Subsection "Miscellaneous Changes".IP "\(bu" 4\&\s-1AUTOLOAD\s0 is now lvaluable, meaning that you can add the :lvalue attributeto \s-1AUTOLOAD\s0 subroutines and you can assign to the \s-1AUTOLOAD\s0 return value..IP "\(bu" 4The \f(CW$Config\fR{byteorder} (and corresponding \s-1BYTEORDER\s0 in config.h) waspreviously wrong in platforms if sizeof(long) was 4, but sizeof(\s-1IV\s0)was 8. The byteorder was only sizeof(long) bytes long (1234 or 4321),but now it is correctly sizeof(\s-1IV\s0) bytes long, (12345678 or 87654321).(This problem didn't affect Windows platforms.).SpAlso, \f(CW$Config\fR{byteorder} is now computed dynamically\*(--this is morerobust with \*(L"fat binaries\*(R" where an executable image contains binariesfor more than one binary platform, and when cross-compiling..IP "\(bu" 4\&\f(CW\*(C`perl \-d:Module=arg,arg,arg\*(C'\fR now works (previously one couldn't passin multiple arguments.).IP "\(bu" 4\&\f(CW\*(C`do\*(C'\fR followed by a bareword now ensures that this bareword isn'ta keyword (to avoid a bug where \f(CW\*(C`do q(foo.pl)\*(C'\fR tried to call asubroutine called \f(CW\*(C`q\*(C'\fR). This means that for example instead of\&\f(CW\*(C`do format()\*(C'\fR you must write \f(CW\*(C`do &format()\*(C'\fR..IP "\(bu" 4The builtin \fIdump()\fR now gives an optional warning\&\f(CW\*(C`dump() better written as CORE::dump()\*(C'\fR,meaning that by default \f(CW\*(C`dump(...)\*(C'\fR is resolved as the builtin\&\fIdump()\fR which dumps core and aborts, not as (possibly) user-defined\&\f(CW\*(C`sub dump\*(C'\fR. To call the latter, qualify the call as \f(CW\*(C`&dump(...)\*(C'\fR.(The whole \fIdump()\fR feature is to considered deprecated, and possiblyremoved/changed in future releases.).IP "\(bu" 4\&\fIchomp()\fR and \fIchop()\fR are now overridable. Note, however, that theirprototype (as given by \f(CW\*(C`prototype("CORE::chomp")\*(C'\fR is undefined,because it cannot be expressed and therefore one cannot really writereplacements to override these builtins..IP "\(bu" 4\&\s-1END\s0 blocks are now run even if you exit/die in a \s-1BEGIN\s0 block.Internally, the execution of \s-1END\s0 blocks is now controlled byPL_exit_flags & \s-1PERL_EXIT_DESTRUCT_END\s0. This enables the newbehaviour for Perl embedders. This will default in 5.10. Seeperlembed..IP "\(bu" 4Formats now support zero-padded decimal fields..IP "\(bu" 4Although \*(L"you shouldn't do that\*(R", it was possible to write code thatdepends on Perl's hashed key order (Data::Dumper does this). The newalgorithm \*(L"One-at-a-Time\*(R" produces a different hashed key order.More details are in \*(L"Performance Enhancements\*(R"..IP "\(bu" 4lstat(\s-1FILEHANDLE\s0) now gives a warning because the operation makes no sense.In future releases this may become a fatal error..IP "\(bu" 4Spurious syntax errors generated in certain situations, when \fIglob()\fRcaused File::Glob to be loaded for the first time, have been fixed. [561].IP "\(bu" 4Lvalue subroutines can now return \f(CW\*(C`undef\*(C'\fR in list context. However,the lvalue subroutine feature still remains experimental. [561+].IP "\(bu" 4A lost warning \*(L"Can't declare ... dereference in my\*(R" has beenrestored (Perl had it earlier but it became lost in later releases.).IP "\(bu" 4A new special regular expression variable has been introduced:\&\f(CW$^N\fR, which contains the most-recently closed group (submatch)..IP "\(bu" 4\&\f(CW\*(C`no Module;\*(C'\fR does not produce an error even if Module does not have an\&\fIunimport()\fR method. This parallels the behavior of \f(CW\*(C`use\*(C'\fR vis-a-vis\&\f(CW\*(C`import\*(C'\fR. [561].IP "\(bu" 4The numerical comparison operators return \f(CW\*(C`undef\*(C'\fR if either operandis a NaN. Previously the behaviour was unspecified..IP "\(bu" 4\&\f(CW\*(C`our\*(C'\fR can now have an experimental optional attribute \f(CW\*(C`unique\*(C'\fR thataffects how global variables are shared among multiple interpreters,see \*(L"our\*(R" in perlfunc..IP "\(bu" 4The following builtin functions are now overridable: \fIeach()\fR, \fIkeys()\fR,\&\fIpop()\fR, \fIpush()\fR, \fIshift()\fR, \fIsplice()\fR, \fIunshift()\fR. [561].IP "\(bu" 4\&\f(CW\*(C`pack() / unpack()\*(C'\fR can now group template letters with \f(CW\*(C`()\*(C'\fR and thenapply repetition/count modifiers on the groups..IP "\(bu" 4\&\f(CW\*(C`pack() / unpack()\*(C'\fR can now process the Perl internal numeric types:IVs, UVs, NVs\*(-- and also long doubles, if supported by the platform.The template letters are \f(CW\*(C`j\*(C'\fR, \f(CW\*(C`J\*(C'\fR, \f(CW\*(C`F\*(C'\fR, and \f(CW\*(C`D\*(C'\fR..IP "\(bu" 4\&\f(CW\*(C`pack(\*(AqU0a*\*(Aq, ...)\*(C'\fR can now be used to force a string to \s-1UTF\-8\s0..IP "\(bu" 4my _\|_PACKAGE_\|_ \f(CW$obj\fR now works. [561].IP "\(bu" 4\&\fIPOSIX::sleep()\fR now returns the number of \fIunslept\fR seconds(as the \s-1POSIX\s0 standard says), as opposed to \fICORE::sleep()\fR whichreturns the number of slept seconds..IP "\(bu" 4\&\fIprintf()\fR and \fIsprintf()\fR now support parameter reordering using the\&\f(CW\*(C`%\ed+\e$\*(C'\fR and \f(CW\*(C`*\ed+\e$\*(C'\fR syntaxes. For example.Sp.Vb 1\& printf "%2\e$s %1\e$s\en", "foo", "bar";.Ve.Spwill print \*(L"bar foo\en\*(R". This feature helps in writinginternationalised software, and in general when the orderof the parameters can vary..IP "\(bu" 4The (\e&) prototype now works properly. [561].IP "\(bu" 4prototype(\e[$@%&]) is now available to implicitly create references(useful for example if you want to emulate the \fItie()\fR interface)..IP "\(bu" 4A new command-line option, \f(CW\*(C`\-t\*(C'\fR is available. It is thelittle brother of \f(CW\*(C`\-T\*(C'\fR: instead of dying on taint violations,lexical warnings are given. \fBThis is only meant as a temporarydebugging aid while securing the code of old legacy applications.This is not a substitute for \-T.\fR.IP "\(bu" 4In other taint news, the \f(CW\*(C`exec LIST\*(C'\fR and \f(CW\*(C`system LIST\*(C'\fR have now beenconsidered too risky (think \f(CW\*(C`exec @ARGV\*(C'\fR: it can start any programwith any arguments), and now the said forms cause a warning underlexical warnings. You should carefully launder the arguments toguarantee their validity. In future releases of Perl the forms willbecome fatal errors so consider starting laundering now..IP "\(bu" 4Tied hash interfaces are now required to have the \s-1EXISTS\s0 and \s-1DELETE\s0methods (either own or inherited)..IP "\(bu" 4If tr/// is just counting characters, it doesn't attempt tomodify its target..IP "\(bu" 4\&\fIuntie()\fR will now call an \s-1\fIUNTIE\s0()\fR hook if it exists. See perltiefor details. [561].IP "\(bu" 4utime now supports \f(CW\*(C`utime undef, undef, @files\*(C'\fR to change thefile timestamps to the current time..IP "\(bu" 4The rules for allowing underscores (underbars) in numeric constantshave been relaxed and simplified: now you can have an underscoresimply \fBbetween digits\fR..IP "\(bu" 4Rather than relying on C's argv[0] (which may not contain a full pathname)where possible $^X is now set by asking the operating system.(eg by reading \fI/proc/self/exe\fR on Linux, \fI/proc/curproc/file\fR on FreeBSD).IP "\(bu" 4A new variable, \f(CW\*(C`${^TAINT}\*(C'\fR, indicates whether taint mode is enabled..IP "\(bu" 4You can now override the \fIreadline()\fR builtin, and this overrides alsothe <\s-1FILEHANDLE\s0> angle bracket operator..IP "\(bu" 4The command-line options \-s and \-F are now recognized on the shebang(#!) line..IP "\(bu" 4Use of the \f(CW\*(C`/c\*(C'\fR match modifier without an accompanying \f(CW\*(C`/g\*(C'\fR modifierelicits a new warning: \f(CW\*(C`Use of /c modifier is meaningless without /g\*(C'\fR..SpUse of \f(CW\*(C`/c\*(C'\fR in substitutions, even with \f(CW\*(C`/g\*(C'\fR, elicits\&\f(CW\*(C`Use of /c modifier is meaningless in s///\*(C'\fR..SpUse of \f(CW\*(C`/g\*(C'\fR with \f(CW\*(C`split\*(C'\fR elicits \f(CW\*(C`Use of /g modifier is meaninglessin split\*(C'\fR..IP "\(bu" 4Support for the \f(CW\*(C`CLONE\*(C'\fR special subroutine had been added.With ithreads, when a new thread is created, all Perl data is cloned,however non-Perl data cannot be cloned automatically. In \f(CW\*(C`CLONE\*(C'\fR youcan do whatever you need to do, like for example handle the cloning ofnon-Perl data, if necessary. \f(CW\*(C`CLONE\*(C'\fR will be executed once for everypackage that has it defined or inherited. It will be called in thecontext of the new thread, so all modifications are made in the new area..SpSee perlmod.SH "Modules and Pragmata".IX Header "Modules and Pragmata".Sh "New Modules and Pragmata".IX Subsection "New Modules and Pragmata".IP "\(bu" 4\&\f(CW\*(C`Attribute::Handlers\*(C'\fR, originally by Damian Conway and now maintainedby Arthur Bergman, allows a class to define attribute handlers..Sp.Vb 3\& package MyPack;\& use Attribute::Handlers;\& sub Wolf :ATTR(SCALAR) { print "howl!\en" }\&\& # later, in some package using or inheriting from MyPack...\&\& my MyPack $Fluffy : Wolf; # the attribute handler Wolf will be called.Ve.SpBoth variables and routines can have attribute handlers. Handlers canbe specific to type (\s-1SCALAR\s0, \s-1ARRAY\s0, \s-1HASH\s0, or \s-1CODE\s0), or specific to theexact compilation phase (\s-1BEGIN\s0, \s-1CHECK\s0, \s-1INIT\s0, or \s-1END\s0).See Attribute::Handlers..IP "\(bu" 4\&\f(CW\*(C`B::Concise\*(C'\fR, by Stephen McCamant, is a new compiler backend forwalking the Perl syntax tree, printing concise info about ops.The output is highly customisable. See B::Concise. [561+].IP "\(bu" 4The new bignum, bigint, and bigrat pragmas, by Tels, implementtransparent bignum support (using the Math::BigInt, Math::BigFloat,and Math::BigRat backends)..IP "\(bu" 4\&\f(CW\*(C`Class::ISA\*(C'\fR, by Sean Burke, is a module for reporting the searchpath for a class's \s-1ISA\s0 tree. See Class::ISA..IP "\(bu" 4\&\f(CW\*(C`Cwd\*(C'\fR now has a split personality: if possible, an \s-1XS\s0 extension isused, (this will hopefully be faster, more secure, and more robust)but if not possible, the familiar Perl implementation is used..IP "\(bu" 4\&\f(CW\*(C`Devel::PPPort\*(C'\fR, originally by Kenneth Albanowski and nowmaintained by Paul Marquess, has been added. It is primarily usedby \f(CW\*(C`h2xs\*(C'\fR to enhance portability of \s-1XS\s0 modules between differentversions of Perl. See Devel::PPPort..IP "\(bu" 4\&\f(CW\*(C`Digest\*(C'\fR, frontend module for calculating digests (checksums), fromGisle Aas, has been added. See Digest..IP "\(bu" 4\&\f(CW\*(C`Digest::MD5\*(C'\fR for calculating \s-1MD5\s0 digests (checksums) as defined in\&\s-1RFC\s0 1321, from Gisle Aas, has been added. See Digest::MD5..Sp.Vb 1\& use Digest::MD5 \*(Aqmd5_hex\*(Aq;\&\& $digest = md5_hex("Thirsty Camel");\&\& print $digest, "\en"; # 01d19d9d2045e005c3f1b80e8b164de1.Ve.Sp\&\s-1NOTE:\s0 the \f(CW\*(C`MD5\*(C'\fR backward compatibility module is deliberately notincluded since its further use is discouraged..SpSee also PerlIO::via::QuotedPrint..IP "\(bu" 4\&\f(CW\*(C`Encode\*(C'\fR, originally by Nick Ing-Simmons and now maintained by DanKogai, provides a mechanism to translate between different characterencodings. Support for Unicode, \s-1ISO\-8859\-1\s0, and \s-1ASCII\s0 are compiled into the module. Several other encodings (like the rest of the\&\s-1ISO\-8859\s0, CP*/Win*, Mac, \s-1KOI8\-R\s0, three variants \s-1EBCDIC\s0, Chinese,Japanese, and Korean encodings) are included and can be loaded atruntime. (For space considerations, the largest Chinese encodingshave been separated into their own \s-1CPAN\s0 module, Encode::HanExtra,which Encode will use if available). See Encode..SpAny encoding supported by Encode module is also available to the\&\*(L":\fIencoding()\fR\*(R" layer if PerlIO is used..IP "\(bu" 4\&\f(CW\*(C`Hash::Util\*(C'\fR is the interface to the new \fIrestricted hashes\fRfeature. (Implemented by Jeffrey Friedl, Nick Ing-Simmons, andMichael Schwern.) See Hash::Util..IP "\(bu" 4\&\f(CW\*(C`I18N::Langinfo\*(C'\fR can be used to query locale information.See I18N::Langinfo..IP "\(bu" 4\&\f(CW\*(C`I18N::LangTags\*(C'\fR, by Sean Burke, has functions for dealing withRFC3066\-style language tags. See I18N::LangTags..IP "\(bu" 4\&\f(CW\*(C`ExtUtils::Constant\*(C'\fR, by Nicholas Clark, is a new tool for extensionwriters for generating \s-1XS\s0 code to import C header constants.See ExtUtils::Constant..IP "\(bu" 4\&\f(CW\*(C`Filter::Simple\*(C'\fR, by Damian Conway, is an easy-to-use frontend toFilter::Util::Call. See Filter::Simple..Sp.Vb 1\& # in MyFilter.pm:\&\& package MyFilter;\&\& use Filter::Simple sub {\& while (my ($from, $to) = splice @_, 0, 2) {\& s/$from/$to/g;\& }\& };\&\& 1;\&\& # in user\*(Aqs code:\&\& use MyFilter qr/red/ => \*(Aqgreen\*(Aq;\&\& print "red\en"; # this code is filtered, will print "green\en"\& print "bored\en"; # this code is filtered, will print "bogreen\en"\&\& no MyFilter;\&\& print "red\en"; # this code is not filtered, will print "red\en".Ve.IP "\(bu" 4\&\f(CW\*(C`File::Temp\*(C'\fR, by Tim Jenness, allows one to create temporary files
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -