📄 perl571delta.pod
字号:
=head1 NAMEperl571delta - what's new for perl v5.7.1=head1 DESCRIPTIONThis document describes differences between the 5.7.0 release and the5.7.1 release. (To view the differences between the 5.6.0 release and the 5.7.0release, see L<perl570delta>.)=head1 Security Vulnerability Closed(This change was already made in 5.7.0 but bears repeating here.)A potential security vulnerability in the optional suidperl componentof Perl was identified in August 2000. suidperl is neither built norinstalled by default. As of April 2001 the only known vulnerableplatform is Linux, most likely all Linux distributions. CERT andvarious vendors and distributors have been alerted about the vulnerability.See http://www.cpan.org/src/5.0/sperl-2000-08-05/sperl-2000-08-05.txtfor more information.The problem was caused by Perl trying to report a suspected securityexploit attempt using an external program, /bin/mail. On Linuxplatforms the /bin/mail program had an undocumented feature whichwhen combined with suidperl gave access to a root shell, resulting ina serious compromise instead of reporting the exploit attempt. If youdon't have /bin/mail, or if you have 'safe setuid scripts', or ifsuidperl is not installed, you are safe.The exploit attempt reporting feature has been completely removed fromall the Perl 5.7 releases (and will be gone also from the maintenancerelease 5.6.1), so that particular vulnerability isn't there anymore.However, further security vulnerabilities are, unfortunately, alwayspossible. The suidperl code is being reviewed and if deemed too riskyto continue to be supported, it may be completely removed from futurereleases. In any case, suidperl should only be used by securityexperts who know exactly what they are doing and why they are usingsuidperl instead of some other solution such as sudo( see http://www.courtesan.com/sudo/ ).=head1 Incompatible Changes=over 4=item *Although "you shouldn't do that", it was possible to write code thatdepends on Perl's hashed key order (Data::Dumper does this). The newalgorithm "One-at-a-Time" produces a different hashed key order.More details are in L</"Performance Enhancements">.=item *The list of filenames from glob() (or <...>) is now by default sortedalphabetically to be csh-compliant. (bsd_glob() does still sort platformnatively, ASCII or EBCDIC, unless GLOB_ALPHASORT is specified.)=back=head1 Core Enhancements=head2 AUTOLOAD Is Now LvaluableAUTOLOAD is now lvaluable, meaning that you can add the :lvalue attributeto AUTOLOAD subroutines and you can assign to the AUTOLOAD return value.=head2 PerlIO is Now The Default=over 4=item *IO is now by default done via PerlIO rather than system's "stdio".PerlIO allows "layers" to be "pushed" onto a file handle to alter thehandle's behaviour. Layers can be specified at open time via 3-argform of open: open($fh,'>:crlf :utf8', $path) || ...or on already opened handles via extended C<binmode>: binmode($fh,':encoding(iso-8859-7)');The built-in layers are: unix (low level read/write), stdio (as inprevious Perls), perlio (re-implementation of stdio buffering in aportable manner), crlf (does CRLF <=> "\n" translation as on Win32,but available on any platform). A mmap layer may be available ifplatform supports it (mostly UNIXes).Layers to be applied by default may be specified via the 'open' pragma.See L</"Installation and Configuration Improvements"> for the effectsof PerlIO on your architecture name.=item *File handles can be marked as accepting Perl's internal encoding of Unicode(UTF-8 or UTF-EBCDIC depending on platform) by a pseudo layer ":utf8" : open($fh,">:utf8","Uni.txt");Note for EBCDIC users: the pseudo layer ":utf8" is erroneously namedfor you since it's not UTF-8 what you will be getting but insteadUTF-EBCDIC. See L<perlunicode>, L<utf8>, andhttp://www.unicode.org/unicode/reports/tr16/ for more information.In future releases this naming may change.=item *File handles can translate character encodings from/to Perl's internalUnicode form on read/write via the ":encoding()" layer.=item *File handles can be opened to "in memory" files held in Perl scalars via: open($fh,'>', \$variable) || ...=item *Anonymous temporary files are available without need to'use FileHandle' or other module via open($fh,"+>", undef) || ...That is a literal undef, not an undefined value.=item *The list form of C<open> is now implemented for pipes (at least on UNIX): open($fh,"-|", 'cat', '/etc/motd')creates a pipe, and runs the equivalent of exec('cat', '/etc/motd') inthe child process.=item *The following builtin functions are now overridable: chop(), chomp(),each(), keys(), pop(), push(), shift(), splice(), unshift().=item *Formats now support zero-padded decimal fields.=item *Perl now tries internally to use integer values in numeric conversionsand basic arithmetics (+ - * /) if the arguments are integers, andtries also to keep the results stored internally as integers.This change leads into often slightly faster and always less lossyarithmetics. (Previously Perl always preferred floating point numbersin its math.)=item *The printf() and sprintf() now support parameter reordering using theC<%\d+\$> and C<*\d+\$> syntaxes. For example print "%2\$s %1\$s\n", "foo", "bar";will print "bar foo\n"; This feature helps in writinginternationalised software.=item *Unicode in general should be now much more usable. Unicode can beused in hash keys, Unicode in regular expressions should work now,Unicode in tr/// should work now (though tr/// seems to be aparticularly tricky to get right, so you have been warned)=item *The Unicode Character Database coming with Perl has been upgradedto Unicode 3.1. For more information, see http://www.unicode.org/ ,and http://www.unicode.org/unicode/reports/tr27/For developers interested in enhancing Perl's Unicode capabilities:almost all the UCD files are included with the Perl distribution inthe lib/unicode subdirectory. The most notable omission, for spaceconsiderations, is the Unihan database.=item *The Unicode character classes \p{Blank} and \p{SpacePerl} have beenadded. "Blank" is like C isblank(), that is, it contains only"horizontal whitespace" (the space character is, the newline isn't),and the "SpacePerl" is the Unicode equivalent of C<\s> (\p{Space}isn't, since that includes the vertical tabulator character, whereasC<\s> doesn't.)=back=head2 Signals Are Now SafePerl used to be fragile in that signals arriving at inopportune momentscould corrupt Perl's internal state.=head1 Modules and Pragmata=head2 New Modules=over 4=item *B::Concise, by Stephen McCamant, is a new compiler backend forwalking the Perl syntax tree, printing concise info about ops.The output is highly customisable.See L<B::Concise> for more information.=item *Class::ISA, by Sean Burke, for reporting the search path for aclass's ISA tree, has been added.See L<Class::ISA> for more information.=item *Cwd has now a split personality: if possible, an extension is used,(this will hopefully be both faster and more secure and robust) butif not possible, the familiar Perl library implementation is used.=item *Digest, a frontend module for calculating digests (checksums),from Gisle Aas, has been added.See L<Digest> for more information.=item *Digest::MD5 for calculating MD5 digests (checksums), by Gisle Aas,has been added. use Digest::MD5 'md5_hex'; $digest = md5_hex("Thirsty Camel"); print $digest, "\n"; # 01d19d9d2045e005c3f1b80e8b164de1NOTE: the MD5 backward compatibility module is deliberately notincluded since its use is discouraged.See L<Digest::MD5> for more information.=item *Encode, by Nick Ing-Simmons, provides a mechanism to translatebetween different character encodings. Support for Unicode,ISO-8859-*, ASCII, CP*, KOI8-R, and three variants of EBCDIC arecompiled in to the module. Several other encodings (like Japanese,Chinese, and MacIntosh encodings) are included and will be loaded atruntime.Any encoding supported by Encode module is also available to the":encoding()" layer if PerlIO is used.See L<Encode> for more information.=item *Filter::Simple is an easy-to-use frontend to Filter::Util::Call,from Damian Conway. # in MyFilter.pm: package MyFilter; use Filter::Simple sub { while (my ($from, $to) = splice @_, 0, 2) { s/$from/$to/g; } }; 1; # in user's code: use MyFilter qr/red/ => 'green'; print "red\n"; # this code is filtered, will print "green\n" print "bored\n"; # this code is filtered, will print "bogreen\n" no MyFilter; print "red\n"; # this code is not filtered, will print "red\n"See L<Filter::Simple> for more information.=item *Filter::Util::Call, by Paul Marquess, provides you with theframework to write I<Source Filters> in Perl. For most usesthe frontend Filter::Simple is to be preferred.See L<Filter::Util::Call> for more information.=item *Locale::Constants, Locale::Country, Locale::Currency, and Locale::Language,from Neil Bowers, have been added. They provide the codes for variouslocale standards, such as "fr" for France, "usd" for US Dollar, and"jp" for Japanese. use Locale::Country; $country = code2country('jp'); # $country gets 'Japan' $code = country2code('Norway'); # $code gets 'no'See L<Locale::Constants>, L<Locale::Country>, L<Locale::Currency>,and L<Locale::Language> for more information.=item *MIME::Base64, by Gisle Aas, allows you to encode data in base64. use MIME::Base64; $encoded = encode_base64('Aladdin:open sesame'); $decoded = decode_base64($encoded); print $encoded, "\n"; # "QWxhZGRpbjpvcGVuIHNlc2FtZQ=="See L<MIME::Base64> for more information.=item *MIME::QuotedPrint, by Gisle Aas, allows you to encode data inquoted-printable encoding. use MIME::QuotedPrint; $encoded = encode_qp("Smiley in Unicode: \x{263a}"); $decoded = decode_qp($encoded); print $encoded, "\n"; # "Smiley in Unicode: =263A"MIME::QuotedPrint has been enhanced to provide the basic methodsnecessary to use it with PerlIO::Via as in : use MIME::QuotedPrint; open($fh,">Via(MIME::QuotedPrint)",$path)See L<MIME::QuotedPrint> for more information.=item *PerlIO::Scalar, by Nick Ing-Simmons, provides the implementation ofIO to "in memory" Perl scalars as discussed above. It also serves asan example of a loadable layer. Other future possibilities includePerlIO::Array and PerlIO::Code. See L<PerlIO::Scalar> for moreinformation.=item *PerlIO::Via, by Nick Ing-Simmons, acts as a PerlIO layer and wrapsPerlIO layer functionality provided by a class (typically implementedin perl code). use MIME::QuotedPrint; open($fh,">Via(MIME::QuotedPrint)",$path)This will automatically convert everything output to C<$fh>to Quoted-Printable. See L<PerlIO::Via> for more information.=item *Pod::Text::Overstrike, by Joe Smith, has been added.It converts POD data to formatted overstrike text.See L<Pod::Text::Overstrike> for more information.=item *Switch from Damian Conway has been added. Just by saying use Switch;you have C<switch> and C<case> available in Perl. use Switch; switch ($val) { case 1 { print "number 1" } case "a" { print "string a" } case [1..10,42] { print "number in list" } case (@array) { print "number in list" } case /\w+/ { print "pattern" } case qr/\w+/ { print "pattern" } case (%hash) { print "entry in hash" } case (\%hash) { print "entry in hash" } case (\&sub) { print "arg to subroutine" } else { print "previous case not true" } }See L<Switch> for more information.=item *Text::Balanced from Damian Conway has been added, forextracting delimited text sequences from strings. use Text::Balanced 'extract_delimited'; ($a, $b) = extract_delimited("'never say never', he never said", "'", '');$a will be "'never say never'", $b will be ', he never said'.In addition to extract_delimited() there are also extract_bracketed(),extract_quotelike(), extract_codeblock(), extract_variable(),extract_tagged(), extract_multiple(), gen_delimited_pat(), andgen_extract_tagged(). With these you can implement rather advancedparsing algorithms. See L<Text::Balanced> for more information.=item *Tie::RefHash::Nestable, by Edward Avis, allows storing hash references(unlike the standard Tie::RefHash) The module is contained withinTie::RefHash.=item *XS::Typemap, by Tim Jenness, is a test extension that exercises XStypemaps. Nothing gets installed but for extension writers the codeis worth studying.=back=head2 Updated And Improved Modules and Pragmata=over 4=item *B::Deparse should be now more robust. It still far from providing a fullround trip for any random piece of Perl code, though, and is under activedevelopment: expect more robustness in 5.7.2.=item *Class::Struct can now define the classes in compile time.=item *Math::BigFloat has undergone much fixing, and in addition the fmod()function now supports modulus operations.( The fixed Math::BigFloat module is also available in CPAN for thosewho can't upgrade their Perl: http://www.cpan.org/authors/id/J/JP/JPEACOCK/ )=item *Devel::Peek now has an interface for the Perl memory statistics(this works only if you are using perl's malloc, and if you havecompiled with debugging).=item *IO::Socket has now atmark() method, which returns true if the socketis positioned at the out-of-band mark. The method is also exportableas a sockatmark() function.=item *IO::Socket::INET has support for ReusePort option (if your platformsupports it). The Reuse option now has an alias, ReuseAddr. For clarityyou may want to prefer ReuseAddr.=item *Net::Ping has been enhanced. There is now "external" protocol whichuses Net::Ping::External module which runs external ping(1) and parsesthe output. An alpha version of Net::Ping::External is available inCPAN and in 5.7.2 the Net::Ping::External may be integrated to Perl.=item *The C<open> pragma allows layers other than ":raw" and ":crlf" whenusing PerlIO.=item *POSIX::sigaction() is now much more flexible and robust.You can now install coderef handlers, 'DEFAULT', and 'IGNORE'handlers, installing new handlers was not atomic.=item *The Test module has been significantly enhanced. Its use isgreatly recommended for module writers.=item *The utf8:: name space (as in the pragma) provides variousPerl-callable functions to provide low level access to Perl'sinternal Unicode representation. At the moment only length()has been implemented.=backThe following modules have been upgraded from the versions at CPAN:CPAN, CGI, DB_File, File::Temp, Getopt::Long, Pod::Man, Pod::Text,Storable, Text-Tabs+Wrap.=head1 Performance Enhancements=over 4=item *Hashes now use Bob Jenkins "One-at-a-Time" hashing key algorithm( http://burtleburtle.net/bob/hash/doobs.html ). This algorithm isreasonably fast while producing a much better spread of values thanthe old hashing algorithm (originally by Chris Torek, later tweaked byIlya Zakharevich). Hash values output from the algorithm on a hash ofall 3-char printable ASCII keys comes much closer to passing theDIEHARD random number generation tests. According to perlbench, thischange has not affected the overall speed of Perl.=item *unshift() should now be noticeably faster.=back=head1 Utility Changes=over 4=item *h2xs now produces template README.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -