📄 perl5005delta.pod
字号:
=head1 NAMEperl5005delta - what's new for perl5.005=head1 DESCRIPTIONThis document describes differences between the 5.004 release and this one.=head1 About the new versioning systemPerl is now developed on two tracks: a maintenance track that makessmall, safe updates to released production versions with emphasis oncompatibility; and a development track that pursues more aggressiveevolution. Maintenance releases (which should be considered productionquality) have subversion numbers that run from C<1> to C<49>, anddevelopment releases (which should be considered "alpha" quality) runfrom C<50> to C<99>.Perl 5.005 is the combined product of the new dual-track developmentscheme.=head1 Incompatible Changes=head2 WARNING: This version is not binary compatible with Perl 5.004.Starting with Perl 5.004_50 there were many deep and far-reaching changesto the language internals. If you have dynamically loaded extensionsthat you built under perl 5.003 or 5.004, you can continue to use themwith 5.004, but you will need to rebuild and reinstall those extensionsto use them 5.005. See F<INSTALL> for detailed instructions on how toupgrade.=head2 Default installation structure has changedThe new Configure defaults are designed to allow a smooth upgrade from5.004 to 5.005, but you should read F<INSTALL> for a detaileddiscussion of the changes in order to adapt them to your system.=head2 Perl Source CompatibilityWhen none of the experimental features are enabled, there should bevery few user-visible Perl source compatibility issues.If threads are enabled, then some caveats apply. C<@_> and C<$_> becomelexical variables. The effect of this should be largely transparent tothe user, but there are some boundary conditions under which user willneed to be aware of the issues. For example, C<local(@_)> results ina "Can't localize lexical variable @_ ..." message. This may be enabledin a future version.Some new keywords have been introduced. These are generally expected tohave very little impact on compatibility. See L<New C<INIT> keyword>,L<New C<lock> keyword>, and L<New C<qrE<sol>E<sol>> operator>.Certain barewords are now reserved. Use of these will provoke a warningif you have asked for them with the C<-w> switch.See L<C<our> is now a reserved word>.=head2 C Source CompatibilityThere have been a large number of changes in the internals to supportthe new features in this release.=over 4=item *Core sources now require ANSI C compilerAn ANSI C compiler is now B<required> to build perl. See F<INSTALL>.=item *All Perl global variables must now be referenced with an explicit prefixAll Perl global variables that are visible for use by extensions nowhave a C<PL_> prefix. New extensions should C<not> refer to perl globalsby their unqualified names. To preserve sanity, we provide limitedbackward compatibility for globals that are being widely used likeC<sv_undef> and C<na> (which should now be written as C<PL_sv_undef>,C<PL_na> etc.)If you find that your XS extension does not compile anymore because aperl global is not visible, try adding a C<PL_> prefix to the globaland rebuild.It is strongly recommended that all functions in the Perl API that don'tbegin with C<perl> be referenced with a C<Perl_> prefix. The bare functionnames without the C<Perl_> prefix are supported with macros, but thissupport may cease in a future release.See L<perlapi>.=item *Enabling threads has source compatibility issuesPerl built with threading enabled requires extensions to use the newC<dTHR> macro to initialize the handle to access per-thread data.If you see a compiler error that talks about the variable C<thr> notbeing declared (when building a module that has XS code), you needto add C<dTHR;> at the beginning of the block that elicited the error.The API function C<perl_get_sv("@",FALSE)> should be used instead ofdirectly accessing perl globals as C<GvSV(errgv)>. The API call isbackward compatible with existing perls and provides source compatibilitywith threading is enabled.See L<"C Source Compatibility"> for more information.=back=head2 Binary CompatibilityThis version is NOT binary compatible with older versions. All extensionswill need to be recompiled. Further binaries built with threads enabledare incompatible with binaries built without. This should largely betransparent to the user, as all binary incompatible configurations havetheir own unique architecture name, and extension binaries get installed atunique locations. This allows coexistence of several configurations inthe same directory hierarchy. See F<INSTALL>.=head2 Security fixes may affect compatibilityA few taint leaks and taint omissions have been corrected. This may leadto "failure" of scripts that used to work with older versions. Compilingwith -DINCOMPLETE_TAINTS provides a perl with minimal amounts of changesto the tainting behavior. But note that the resulting perl will haveknown insecurities.Oneliners with the C<-e> switch do not create temporary files anymore.=head2 Relaxed new mandatory warnings introduced in 5.004Many new warnings that were introduced in 5.004 have been madeoptional. Some of these warnings are still present, but perl's newfeatures make them less often a problem. See L<New Diagnostics>.=head2 LicensingPerl has a new Social Contract for contributors. See F<Porting/Contract>.The license included in much of the Perl documentation has changed.Most of the Perl documentation was previously under the implicit GNUGeneral Public License or the Artistic License (at the user's choice).Now much of the documentation unambiguously states the terms under whichit may be distributed. Those terms are in general much less restrictivethan the GNU GPL. See L<perl> and the individual perl manpages listedtherein.=head1 Core Changes=head2 ThreadsWARNING: Threading is considered an B<experimental> feature. Details of theimplementation may change without notice. There are known limitationsand some bugs. These are expected to be fixed in future versions.See F<README.threads>.=head2 CompilerWARNING: The Compiler and related tools are considered B<experimental>.Features may change without notice, and there are known limitationsand bugs. Since the compiler is fully external to perl, the defaultconfiguration will build and install it.The Compiler produces three different types of transformations of aperl program. The C backend generates C code that captures perl's statejust before execution begins. It eliminates the compile-time overheadsof the regular perl interpreter, but the run-time performance remainscomparatively the same. The CC backend generates optimized C codeequivalent to the code path at run-time. The CC backend has greaterpotential for big optimizations, but only a few optimizations areimplemented currently. The Bytecode backend generates a platformindependent bytecode representation of the interpreter's statejust before execution. Thus, the Bytecode back end also eliminatesmuch of the compilation overhead of the interpreter.The compiler comes with several valuable utilities.C<B::Lint> is an experimental module to detect and warn about suspiciouscode, especially the cases that the C<-w> switch does not detect.C<B::Deparse> can be used to demystify perl code, and understandhow perl optimizes certain constructs.C<B::Xref> generates cross reference reports of all definition and useof variables, subroutines and formats in a program.C<B::Showlex> show the lexical variables used by a subroutine or fileat a glance.C<perlcc> is a simple frontend for compiling perl.See C<ext/B/README>, L<B>, and the respective compiler modules.=head2 Regular ExpressionsPerl's regular expression engine has been seriously overhauled, andmany new constructs are supported. Several bugs have been fixed.Here is an itemized summary:=over 4=item Many new and improved optimizationsChanges in the RE engine: Unneeded nodes removed; Substrings merged together; New types of nodes to process (SUBEXPR)* and similar expressions quickly, used if the SUBEXPR has no side effects and matches strings of the same length; Better optimizations by lookup for constant substrings; Better search for constants substrings anchored by $ ;Changes in Perl code using RE engine: More optimizations to s/longer/short/; study() was not working; /blah/ may be optimized to an analogue of index() if $& $` $' not seen; Unneeded copying of matched-against string removed; Only matched part of the string is copying if $` $' were not seen;=item Many bug fixesNote that only the major bug fixes are listed here. See F<Changes> for others. Backtracking might not restore start of $3. No feedback if max count for * or + on "complex" subexpression was reached, similarly (but at compile time) for {3,34567} Primitive restrictions on max count introduced to decrease a possibility of a segfault; (ZERO-LENGTH)* could segfault; (ZERO-LENGTH)* was prohibited; Long REs were not allowed; /RE/g could skip matches at the same position after a zero-length match;=item New regular expression constructsThe following new syntax elements are supported: (?<=RE) (?<!RE) (?{ CODE }) (?i-x) (?i:RE) (?(COND)YES_RE|NO_RE) (?>RE) \z=item New operator for precompiled regular expressionsSee L<New C<qrE<sol>E<sol>> operator>.=item Other improvements Better debugging output (possibly with colors), even from non-debugging Perl; RE engine code now looks like C, not like assembler; Behaviour of RE modifiable by `use re' directive; Improved documentation; Test suite significantly extended; Syntax [:^upper:] etc., reserved inside character classes;=item Incompatible changes (?i) localized inside enclosing group; $( is not interpolated into RE any more; /RE/g may match at the same position (with non-zero length) after a zero-length match (bug fix).=backSee L<perlre> and L<perlop>.=head2 Improved malloc()See banner at the beginning of C<malloc.c> for details.=head2 Quicksort is internally implementedPerl now contains its own highly optimized qsort() routine. The new qsort()is resistant to inconsistent comparison functions, so Perl's C<sort()> willnot provoke coredumps any more when given poorly written sort subroutines.(Some C library C<qsort()>s that were being used before used to have thisproblem.) In our testing, the new C<qsort()> required the minimal numberof pair-wise compares on average, among all known C<qsort()> implementations.See C<perlfunc/sort>.=head2 Reliable signalsPerl's signal handling is susceptible to random crashes, because signalsarrive asynchronously, and the Perl runtime is not reentrant at arbitrarytimes.However, one experimental implementation of reliable signals is availablewhen threads are enabled. See C<Thread::Signal>. Also see F<INSTALL> forhow to build a Perl capable of threads.=head2 Reliable stack pointersThe internals now reallocate the perl stack only at predictable times.In particular, magic calls never trigger reallocations of the stack,because all reentrancy of the runtime is handled using a "stack of stacks".This should improve reliability of cached stack pointers in the internalsand in XSUBs.=head2 More generous treatment of carriage returnsPerl used to complain if it encountered literal carriage returns inscripts. Now they are mostly treated like whitespace within program text.Inside string literals and here documents, literal carriage returns areignored if they occur paired with linefeeds, or get interpreted as whitespaceif they stand alone. This behavior means that literal carriage returnsin files should be avoided. You can get the older, more compatible (butless generous) behavior by defining the preprocessor symbolC<PERL_STRICT_CR> when building perl. Of course, all this has nothingwhatever to do with how escapes like C<\r> are handled within strings.Note that this doesn't somehow magically allow you to keep all text filesin DOS format. The generous treatment only applies to files that perlitself parses. If your C compiler doesn't allow carriage returns infiles, you may still be unable to build modules that need a C compiler.=head2 Memory leaks
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -