X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pod%2Fperldelta.pod;h=2e293419d00148598c9c418df52321918c082c52;hb=dc848c6f6758d4d951bb5c7a9f432e6390e094df;hp=3cd71de7d11c86ad405e26c4f23bd5f2618366e4;hpb=da4fc7d72dff097fbb61b71d560c76cb4e0a1440;p=p5sagit%2Fp5-mst-13.2.git diff --git a/pod/perldelta.pod b/pod/perldelta.pod index 3cd71de..2e29341 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -1,6 +1,6 @@ =head1 NAME -perlnews - what's new for perl5.004 +perldelta - what's new for perl5.004 =head1 DESCRIPTION @@ -18,43 +18,146 @@ QNX, and AmigaOS. Most importantly, many bugs were fixed. See the F file in the distribution for details. -=head2 Compilation Option: Binary Compatibility With 5.003 +=head2 Compilation option: Binary compatibility with 5.003 There is a new Configure question that asks if you want to maintain binary compatibility with Perl 5.003. If you choose binary compatibility, you do not have to recompile your extensions, but you might have symbol conflicts if you embed Perl in another application, -just as in the 5.003 release. +just as in the 5.003 release. By default, binary compatibility +is preserved at the expense of symbol table pollution. -=head2 New Opcode Module and Revised Safe Module +=head2 $PERL5OPT environment variable + +You may now put Perl options in the $PERL5OPT environment variable. +Unless Perl is running with taint checks, it will interpret this +variable as if its contents had appeared on a "#!perl" line at the +beginning of your script, except that hyphens are optional. PERL5OPT +may only be used to set the following switches: B<-[DIMUdmw]>. + +=head2 More precise warnings + +If you removed the B<-w> option from your Perl 5.003 scripts because it +made Perl too verbose, we recommend that you try putting it back when +you upgrade to Perl 5.004. Each new perl version tends to remove some +undesirable warnings, while adding new warnings that may catch bugs in +your scripts. + +=head2 Deprecated: Inherited C for non-methods + +Before Perl 5.004, C functions were looked up as methods +(using the C<@ISA> hierarchy), even when the function to be autoloaded +was called as a plain function (e.g. C), not a method +(e.g. Cbar()> or C<$obj->bar()>). + +Perl 5.005 will use method lookup only for methods' Cs. +However, there is a significant base of existing code that may be using +the old behavior. So, as an interim step, Perl 5.004 issues an optional +warning when a non-method uses an inherited C. + +The simple rule is: Inheritance will not work when autoloading +non-methods. The simple fix for old code is: In any module that used to +depend on inheriting C for non-methods from a base class named +C, execute C<*AUTOLOAD = \&BaseClass::AUTOLOAD> during startup. + +=head2 Subroutine arguments created only when they're modified + +In Perl 5.004, nonexistent array and hash elements used as subroutine +parameters are brought into existence only if they are actually +assigned to (via C<@_>). + +Earlier versions of Perl vary in their handling of such arguments. +Perl versions 5.002 and 5.003 always brought them into existence. +Perl versions 5.000, 5.001, and 5.002 brought them into existence only +if they were not the first argument (which was almost certainly a +bug). Earlier versions of Perl never brought them into existence. + +For example, given this code: + + undef @a; undef %a; + sub show { print $_[0] }; + sub change { $_[0]++ }; + show($a[2]); + change($a{b}); + +After this code executes in Perl 5.004, $a{b} exists but $a[2] does +not. In Perl 5.002 and 5.003, both $a{b} and $a[2] would have existed +(but $a[2]'s value would have been undefined). + +=head2 Fixed parsing of $$, &$, etc. + +A bug in previous versions of Perl 5.0 prevented proper parsing of +numeric special variables as symbolic references. That bug has been +fixed. As a result, the string "$$0" is no longer equivalent to +C<$$."0">, but rather to C<${$0}>. To get the old behavior, change +"$$" followed by a digit to "${$}". + +=head2 No resetting of $. on implicit close + +The documentation for Perl 5.0 has always stated that C<$.> is I +reset when an already-open file handle is reopened with no intervening +call to C. Due to a bug, perl versions 5.000 through 5.003 +I reset C<$.> under that circumstance; Perl 5.004 does not. + +=head2 C may return undef + +The C operator returns true if a subroutine is expected to +return a list, and false otherwise. In Perl 5.004, C can +also return the undefined value if a subroutine's return value will +not be used at all, which allows subroutines to avoid a time-consuming +calculation of a return value if it isn't going to be used. + +=head2 Changes to tainting checks + +A bug in previous versions may have failed to detect some insecure +conditions when taint checks are turned on. (Taint checks are used +in setuid or setgid scripts, or when explicitly turned on with the +C<-T> invocation option.) Although it's unlikely, this may cause a +previously-working script to now fail -- which should be construed +as a blessing, since that indicates a potentially-serious security +hole was just plugged. + +=head2 New Opcode module and revised Safe module A new Opcode module supports the creation, manipulation and application of opcode masks. The revised Safe module has a new API and is implemented using the new Opcode module. Please read the new Opcode and Safe documentation. -=head2 Internal Change: FileHandle Deprecated +=head2 Embedding improvements + +In older versions of Perl it was not possible to create more than one +Perl interpreter instance inside a single process without leaking like a +sieve and/or crashing. The bugs that caused this behavior have all been +fixed. However, you still must take care when embedding Perl in a C +program. See the updated perlembed manpage for tips on how to manage +your interpreters. + +=head2 Internal change: FileHandle class based on IO::* classes + +File handles are now stored internally as type IO::Handle. The +FileHandle module is still supported for backwards compatibility, but +it is now merely a front end to the IO::* modules -- specifically, +IO::Handle, IO::Seekable, and IO::File. We suggest, but do not +require, that you use the IO::* modules in new code. -Filehandles are now stored internally as type IO::Handle. -Although C and C<*STDOUT{FILEHANDLE}> -are still supported for backwards compatibility -C (or C or C) and -C<*STDOUT{IO}> are the way of the future. +In harmony with this change, C<*GLOB{FILEHANDLE}> is now a +backward-compatible synonym for C<*STDOUT{IO}>. -=head2 Internal Change: PerlIO internal IO abstraction interface +=head2 Internal change: PerlIO abstraction interface It is now possible to build Perl with AT&T's sfio IO package instead of stdio. See L for more details, and the F file for how to use it. -=head2 New and Changed Built-in Variables +=head2 New and changed builtin variables =over =item $^E -Extended error message under some platforms ($EXTENDED_OS_ERROR -if you C). +Extended error message on some platforms. (Also known as +$EXTENDED_OS_ERROR if you C). =item $^H @@ -73,14 +176,14 @@ compiled with -DEMERGENCY_SBRK and used Perl's malloc. Then $^M = 'a' x (1<<16); -would allocate 64K buffer for use when in emergency. +would allocate a 64K buffer for use when in emergency. See the F file for information on how to enable this option. As a disincentive to casual use of this advanced feature, there is no C long name for this variable. =back -=head2 New and Changed Built-in Functions +=head2 New and changed builtin functions =over @@ -90,16 +193,21 @@ This now works. (e.g. C) =item flock -is now supported on more platforms, and prefers fcntl -to lockf when emulating. +is now supported on more platforms, prefers fcntl to lockf when +emulating, and always flushes before (un)locking. + +=item printf and sprintf + +now support "%i" as a synonym for "%d", and the "h" modifier. +So "%hi" means "short integer in decimal", and "%ho" means +"unsigned short integer as octal". =item keys as an lvalue As an lvalue, C allows you to increase the number of hash buckets -allocated for the given associative array. This can gain you a measure -of efficiency if you know the hash is going to get big. (This is -similar to pre-extending an array by assigning a larger number to -$#array.) If you say +allocated for the given hash. This can gain you a measure of efficiency if +you know the hash is going to get big. (This is similar to pre-extending +an array by assigning a larger number to $#array.) If you say keys %hash = 200; @@ -115,19 +223,19 @@ as trying has no effect). You can now use my() (with or without the parentheses) in the control expressions of control structures such as: - while (my $line = <>) { + while (defined(my $line = <>)) { $line = lc $line; } continue { print $line; } - if ((my $answer = ) =~ /^yes$/i) { + if ((my $answer = ) =~ /^y(es)?$/i) { user_agrees(); - } elsif ($answer =~ /^no$/i) { + } elsif ($answer =~ /^n(o)?$/i) { user_disagrees(); } else { chomp $answer; - die "'$answer' is neither 'yes' nor 'no'"; + die "`$answer' is neither `yes' nor `no'"; } Also, you can declare a foreach loop control variable as lexical by @@ -156,17 +264,19 @@ which bit eight is clear. If the first argument to C is a number, it is treated as a version number instead of a module name. If the version of the Perl interpreter is less than VERSION, then an error message is printed and Perl exits -immediately. This is often useful if you need to check the current -Perl version before Cing library modules which have changed in -incompatible ways from older versions of Perl. (We try not to do -this more than we have to.) +immediately. Because C occurs at compile time, this check happens +immediately during the compilation process, unlike C, +which waits until runtime for the check. This is often useful if you +need to check the current Perl version before Cing library modules +which have changed in incompatible ways from older versions of Perl. +(We try not to do this more than we have to.) =item use Module VERSION LIST If the VERSION argument is present between Module and LIST, then the C will call the VERSION method in class Module with the given version as an argument. The default VERSION method, inherited from -the Universal class, croaks if the given version is larger than the +the UNIVERSAL class, croaks if the given version is larger than the value of the variable $Module::VERSION. (Note that there is not a comma after VERSION!) @@ -182,12 +292,25 @@ function has no prototype). FUNCTION is a reference to or the name of the function whose prototype you want to retrieve. (Not actually new; just never documented before.) +=item srand + +The default seed for C, which used to be C