[inseparable changes from match from perl-5.003_96 to perl-5.003_97]
[p5sagit/p5-mst-13.2.git] / pod / perldelta.pod
index 3cd71de..2e29341 100644 (file)
@@ -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<Changes>
 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<AUTOLOAD> for non-methods
+
+Before Perl 5.004, C<AUTOLOAD> 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<Foo::bar()>), not a method
+(e.g. C<Foo->bar()> or C<$obj->bar()>).
+
+Perl 5.005 will use method lookup only for methods' C<AUTOLOAD>s.
+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<AUTOLOAD>.
+
+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<AUTOLOAD> for non-methods from a base class named
+C<BaseClass>, 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 $$<digit>, &$<digit>, 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<not>
+reset when an already-open file handle is reopened with no intervening
+call to C<close>.  Due to a bug, perl versions 5.000 through 5.003
+I<did> reset C<$.> under that circumstance; Perl 5.004 does not.
+
+=head2 C<wantarray> may return undef
+
+The C<wantarray> operator returns true if a subroutine is expected to
+return a list, and false otherwise.  In Perl 5.004, C<wantarray> 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<use FileHandle> and C<*STDOUT{FILEHANDLE}>
-are still supported for backwards compatibility
-C<use IO::Handle> (or C<IO::Seekable> or C<IO::File>) 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<perlapio> for more details, and
 the F<INSTALL> 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<use English>).
+Extended error message on some platforms.  (Also known as
+$EXTENDED_OS_ERROR if you C<use English>).
 
 =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<INSTALL> file for information on how to enable this option.
 As a disincentive to casual use of this advanced feature,
 there is no C<use English> 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<delete @ENV{'PATH', 'MANPATH'}>)
 
 =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<keys> 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 = <STDIN>) =~ /^yes$/i) {
+    if ((my $answer = <STDIN>) =~ /^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<use> 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 C<use>ing 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<use> occurs at compile time, this check happens
+immediately during the compilation process, unlike C<require VERSION>,
+which waits until runtime for the check.  This is often useful if you
+need to check the current Perl version before C<use>ing 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<use> 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<srand>, which used to be C<time>, has been changed.
+Now it's a heady mix of difficult-to-predict system-dependent values,
+which should be sufficient for most everyday purposes.
+
+Previous to version 5.004, calling C<rand> without first calling C<srand>
+would yield the same sequence of random numbers on most or all machines.
+Now, when perl sees that you're calling C<rand> and haven't yet called
+C<srand>, it calls C<srand> with the default seed. You should still call
+C<srand> manually if your code might ever be run on a pre-5.004 system,
+of course, or if you want a seed other than the default.
+
 =item $_ as Default
 
 Functions documented in the Camel to default to $_ now in
 fact do, and all those that do are so documented in L<perlfunc>.
 
-=head2 C<m//g> does not trigger a pos() reset on failure
+=item C<m//g> does not trigger a pos() reset on failure
 
 The C<m//g> match iteration construct used to reset the iteration
 when it failed to match (so that the next C<m//g> match would start at
@@ -197,18 +320,46 @@ string in some way.  This change makes it practical to chain C<m//g>
 matches together in conjunction with ordinary matches using the C<\G>
 zero-width assertion.  See L<perlop> and L<perlre>.
 
+=item C<m//x> ignores whitespace before ?*+{}
+
+The C<m//x> construct has always been intended to ignore all unescaped
+whitespace.  However, before Perl 5.004, whitespace had the effect of
+escaping repeat modifiers like "*" or "?"; for example, C</a *b/x> was
+(mis)interpreted as C</a\*b/x>.  This bug has been fixed in 5.004.
+
+=item nested C<sub{}> closures work now
+
+Prior to the 5.004 release, nested anonymous functions didn't work
+right.  They do now.
+
+=item formats work right on changing lexicals
+
+Just like anonymous functions that contain lexical variables
+that change (like a lexical index variable for a C<foreach> loop),
+formats now work properly.  For example, this silently failed
+before, and is fine now:
+
+    my $i;
+    foreach $i ( 1 .. 10 ) {
+       format =
+       my i is @#
+       $i
+    .
+       write;
+    }
+
 =back
 
-=head2 New Built-in Methods
+=head2 New builtin methods
 
 The C<UNIVERSAL> package automatically contains the following methods that
 are inherited by all other classes:
 
-=over 4
+=over
 
 =item isa(CLASS)
 
-C<isa> returns I<true> if its object is blessed into a sub-class of C<CLASS>
+C<isa> returns I<true> if its object is blessed into a subclass of C<CLASS>
 
 C<isa> is also exportable and can be called as a sub with two arguments. This
 allows the ability to check what a reference points to. Example:
@@ -238,27 +389,10 @@ C<VERSION> form of C<use>.
     # implies:
     A->VERSION(1.2);
 
-=item class()
-
-C<class> returns the class name of its object.
-
-=item is_instance()
-
-C<is_instance> returns true if its object is an instance of some
-class, false if its object is the class (package) itself. Example
-
-    A->is_instance();       # False
-
-    $var = 'A';
-    $var->is_instance();    # False
-
-    $ref = bless [], 'A';
-    $ref->is_instance();    # True
-
 =back
 
 B<NOTE:> C<can> directly uses Perl's internal code for method lookup, and
-C<isa> uses a very similar method and cache-ing strategy. This may cause
+C<isa> uses a very similar method and caching strategy. This may cause
 strange effects if the Perl code dynamically changes @ISA in any package.
 
 You may add other methods to the UNIVERSAL class via Perl or XS code.
@@ -266,7 +400,9 @@ You do not need to C<use UNIVERSAL> in order to make these methods
 available to your program.  This is necessary only if you wish to
 have C<isa> available as a plain subroutine in the current package.
 
-=head2 TIEHANDLE Now Supported
+=head2 TIEHANDLE now supported
+
+See L<perltie> for other kinds of tie()s.
 
 =over
 
@@ -276,7 +412,11 @@ This is the constructor for the class.  That means it is expected to
 return an object of some sort. The reference can be used to
 hold some internal information.
 
-    sub TIEHANDLE { print "<shout>\n"; my $i; bless \$i, shift }
+    sub TIEHANDLE {
+       print "<shout>\n";
+       my $i;
+       return bless \$i, shift;
+    }
 
 =item PRINT this, LIST
 
@@ -284,14 +424,38 @@ This method will be triggered every time the tied handle is printed to.
 Beyond its self reference it also expects the list that was passed to
 the print function.
 
-    sub PRINT { $r = shift; $$r++; print join($,,map(uc($_),@_)),$\ }
+    sub PRINT {
+       $r = shift;
+       $$r++;
+       return print join( $, => map {uc} @_), $\;
+    }
+
+=item READ this LIST
+
+This method will be called when the handle is read from via the C<read>
+or C<sysread> functions.
+
+    sub READ {
+       $r = shift;
+       my($buf,$len,$offset) = @_;
+       print "READ called, \$buf=$buf, \$len=$len, \$offset=$offset";
+    }
 
 =item READLINE this
 
 This method will be called when the handle is read from. The method
 should return undef when there is no more data.
 
-    sub READLINE { $r = shift; "PRINT called $$r times\n"; }
+    sub READLINE {
+       $r = shift;
+       return "PRINT called $$r times\n"
+    }
+
+=item GETC this
+
+This method will be called when the C<getc> function is called.
+
+    sub GETC { print "Don't GETC, Get Perl"; return "a"; }
 
 =item DESTROY this
 
@@ -299,18 +463,96 @@ As with the other types of ties, this method will be called when the
 tied handle is about to be destroyed. This is useful for debugging and
 possibly for cleaning up.
 
-    sub DESTROY { print "</shout>\n" }
+    sub DESTROY {
+       print "</shout>\n";
+    }
+
+=back
+
+=head2 Malloc enhancements
+
+Four new compilation flags are recognized by malloc.c.  (They have no
+effect if perl is compiled with system malloc().)
+
+=over
+
+=item -DDEBUGGING_MSTATS
+
+If perl is compiled with C<DEBUGGING_MSTATS> defined, you can print
+memory statistics at runtime by running Perl thusly:
+
+  env PERL_DEBUG_MSTATS=2 perl your_script_here
+
+The value of 2 means to print statistics after compilation and on
+exit; with a value of 1, the statistics ares printed only on exit.
+(If you want the statistics at an arbitrary time, you'll need to
+install the optional module Devel::Peek.)
+
+=item -DEMERGENCY_SBRK
+
+If this macro is defined, running out of memory need not be a fatal
+error: a memory pool can allocated by assigning to the special
+variable C<$^M>.  See L<"$^M">.
+
+=item -DPACK_MALLOC
+
+Perl memory allocation is by bucket with sizes close to powers of two.
+Because of these malloc overhead may be big, especially for data of
+size exactly a power of two.  If C<PACK_MALLOC> is defined, perl uses
+a slightly different algorithm for small allocations (up to 64 bytes
+long), which makes it possible to have overhead down to 1 byte for
+allocations which are powers of two (and appear quite often).
+
+Expected memory savings (with 8-byte alignment in C<alignbytes>) is
+about 20% for typical Perl usage.  Expected slowdown due to additional
+malloc overhead is in fractions of a percent (hard to measure, because
+of the effect of saved memory on speed).
+
+=item -DTWO_POT_OPTIMIZE
+
+Similarly to C<PACK_MALLOC>, this macro improves allocations of data
+with size close to a power of two; but this works for big allocations
+(starting with 16K by default).  Such allocations are typical for big
+hashes and special-purpose scripts, especially image processing.
+
+On recent systems, the fact that perl requires 2M from system for 1M
+allocation will not affect speed of execution, since the tail of such
+a chunk is not going to be touched (and thus will not require real
+memory).  However, it may result in a premature out-of-memory error.
+So if you will be manipulating very large blocks with sizes close to
+powers of two, it would be wise to define this macro.
+
+Expected saving of memory is 0-100% (100% in applications which
+require most memory in such 2**n chunks); expected slowdown is
+negligible.
 
 =back
 
+=head2 Miscellaneous efficiency enhancements
+
+Functions that have an empty prototype and that do nothing but return
+a fixed value are now inlined (e.g. C<sub PI () { 3.14159 }>).
+
+Each unique hash key is only allocated once, no matter how many hashes
+have an entry with that key.  So even if you have 100 copies of the
+same hash, the hash keys never have to be reallocated.
+
 =head1 Pragmata
 
-Three new pragmatic modules exist:
+Six new pragmatic modules exist:
 
 =over
 
+=item use autouse MODULE => qw(sub1 sub2 sub3)
+
+Defers C<require MODULE> until someone calls one of the specified
+subroutines (which must be exported by MODULE).  This pragma should be
+used with caution, and only when necessary.
+
 =item use blib
 
+=item use blib 'dir'
+
 Looks for MakeMaker-like I<'blib'> directory structure starting in
 I<dir> (or current directory) and working back up to five levels of
 parent directories.
@@ -318,10 +560,15 @@ parent directories.
 Intended for use on command line with B<-M> option as a way of testing
 arbitrary scripts against an uninstalled version of a package.
 
+=item use constant NAME => VALUE
+
+Provides a convenient interface for creating compile-time constants,
+See L<perlsub/"Constant Functions">.
+
 =item use locale
 
 Tells the compiler to enable (or disable) the use of POSIX locales for
-built-in operations.
+builtin operations.
 
 When C<use locale> is in effect, the current LC_CTYPE locale is used
 for regular expressions and case mapping; LC_COLLATE for string
@@ -340,13 +587,37 @@ See L<perllocale> for more information.
 
 Disable unsafe opcodes, or any named opcodes, when compiling Perl code.
 
+=item use vmsish
+
+Enable VMS-specific language features.  Currently, there are three
+VMS-specific features available: 'status', which makes C<$?> and
+C<system> return genuine VMS status values instead of emulating POSIX;
+'exit', which makes C<exit> take a genuine VMS status value instead of
+assuming that C<exit 1> is an error; and 'time', which makes all times
+relative to the local time zone, in the VMS tradition.
+
 =back
 
 =head1 Modules
 
-=head2 Module Information Summary
+=head2 Installation directories
+
+The I<installperl> script now places the Perl source files for
+extensions in the architecture-specific library directory, which is
+where the shared libraries for extensions have always been.  This
+change is intended to allow administrators to keep the Perl 5.004
+library directory unchanged from a previous version, without running
+the risk of binary incompatibility between extensions' Perl source and
+shared libraries.
 
-Brand new modules:
+=head2 Module information summary
+
+Brand new modules, arranged by topic rather than strictly
+alphabetically:
+
+    CPAN                 interface to Comprehensive Perl Archive Network
+    CPAN::FirstTime      create a CPAN configuration file
+    CPAN::Nox            run CPAN while avoiding compiled extensions
 
     IO.pm                Top-level interface to IO::* classes
     IO/File.pm           IO::File extension Perl module
@@ -361,7 +632,6 @@ Brand new modules:
     ExtUtils/Embed.pm    Utilities for embedding Perl in C programs
     ExtUtils/testlib.pm  Fixes up @INC to use just-built extension
 
-    Fatal.pm             Make do-or-die equivalents of functions
     FindBin.pm           Find path of currently executing program
 
     Class/Template.pm    Structure/member template builder
@@ -376,10 +646,34 @@ Brand new modules:
     User/grent.pm        Object-oriented wrapper around CORE::getgr*
     User/pwent.pm        Object-oriented wrapper around CORE::getpw*
 
-    lib/Tie/RefHash.pm   Base class for tied hashes with references as keys
+    Tie/RefHash.pm       Base class for tied hashes with references as keys
 
     UNIVERSAL.pm         Base class for *ALL* classes
 
+=head2 Fcntl
+
+New constants in the existing Fcntl modules are now supported,
+provided that your operating system happens to support them:
+
+    F_GETOWN F_SETOWN
+    O_ASYNC O_DEFER O_DSYNC O_FSYNC O_SYNC
+    O_EXLOCK O_SHLOCK
+
+These constants are intended for use with the Perl operators sysopen()
+and fcntl() and the basic database modules like SDBM_File.  For the
+exact meaning of these and other Fcntl constants please refer to your
+operating system's documentation for fcntl() and open().
+
+In addition, the Fcntl module now provides these constants for use
+with the Perl operator flock():
+
+       LOCK_SH LOCK_EX LOCK_NB LOCK_UN
+
+These constants are defined in all environments (because where there is
+no flock() system call, Perl emulates it).  However, for historical
+reasons, these constants are not exported unless they are explicitly
+requested with the ":flock" tag (e.g. C<use Fcntl ':flock'>).
+
 =head2 IO
 
 The IO module provides a simple mechanism to load all of the IO modules at one
@@ -409,9 +703,55 @@ And these functions are now exported:
     sinh cosh tanh cotanh asinh acosh atanh acotanh
     cplx cplxe
 
-=head2 Overridden Built-ins
+=head2 DB_File
+
+There have been quite a few changes made to DB_File. Here are a few of
+the highlights:
+
+=over
+
+=item *
+
+Fixed a handful of bugs.
+
+=item *
+
+By public demand, added support for the standard hash function exists().
+
+=item *
+
+Made it compatible with Berkeley DB 1.86.
+
+=item *
+
+Made negative subscripts work with RECNO interface.
 
-Many of the Perl built-ins returning lists now have
+=item *
+
+Changed the default flags from O_RDWR to O_CREAT|O_RDWR and the default
+mode from 0640 to 0666.
+
+=item *
+
+Made DB_File automatically import the open() constants (O_RDWR,
+O_CREAT etc.) from Fcntl, if available.
+
+=item *
+
+Updated documentation.
+
+=back
+
+Refer to the HISTORY section in DB_File.pm for a complete list of
+changes. Everything after DB_File 1.01 has been added since 5.003.
+
+=head2 Net::Ping
+
+Major rewrite - support added for both udp echo and real icmp pings.
+
+=head2 Object-oriented overrides for builtin operators
+
+Many of the Perl builtins returning lists now have
 object-oriented overrides.  These are:
 
     File::stat
@@ -430,23 +770,72 @@ For example, you can now say
     use User::pwent;
     $his = (stat($filename)->st_uid == pwent($whoever)->pw_uid);
 
-=head1 Efficiency Enhancements
+=head1 Utility Changes
 
-All hash keys with the same string are only allocated once, so
-even if you have 100 copies of the same hash, the immutable keys
-never have to be re-allocated.
+=head2 xsubpp
 
-Functions that have an empty prototype and that do nothing but return
-a fixed value are now inlined (e.g. C<sub PI () { 3.14159 }>).
+=over
+
+=item C<void> XSUBs now default to returning nothing
+
+Due to a documentation/implementation bug in previous versions of
+Perl, XSUBs with a return type of C<void> have actually been
+returning one value.  Usually that value was the GV for the XSUB,
+but sometimes it was some already freed or reused value, which would
+sometimes lead to program failure.
+
+In Perl 5.004, if an XSUB is declared as returning C<void>, it
+actually returns no value, i.e. an empty list (though there is a
+backward-compatibility exception; see below).  If your XSUB really
+does return an SV, you should give it a return type of C<SV *>.
+
+For backward compatibility, I<xsubpp> tries to guess whether a
+C<void> XSUB is really C<void> or if it wants to return an C<SV *>.
+It does so by examining the text of the XSUB: if I<xsubpp> finds
+what looks like an assignment to C<ST(0)>, it assumes that the
+XSUB's return type is really C<SV *>.
+
+=back
+
+=head1 C Language API Changes
+
+=over
+
+=item C<gv_fetchmethod> and C<perl_call_sv>
+
+The C<gv_fetchmethod> function finds a method for an object, just like
+in Perl 5.003.  The GV it returns may be a method cache entry.
+However, in Perl 5.004, method cache entries are not visible to users;
+therefore, they can no longer be passed directly to C<perl_call_sv>.
+Instead, you should use the C<GvCV> macro on the GV to extract its CV,
+and pass the CV to C<perl_call_sv>.
+
+The most likely symptom of passing the result of C<gv_fetchmethod> to
+C<perl_call_sv> is Perl's producing an "Undefined subroutine called"
+error on the I<second> call to a given method (since there is no cache
+on the first call).
+
+=item Extended API for manipulating hashes
+
+Internal handling of hash keys has changed.  The old hashtable API is
+still fully supported, and will likely remain so.  The additions to the
+API allow passing keys as C<SV*>s, so that C<tied> hashes can be given
+real scalars as keys rather than plain strings (nontied hashes still
+can only use strings as keys).  New extensions must use the new hash
+access functions and macros if they wish to use C<SV*> keys.  These
+additions also make it feasible to manipulate C<HE*>s (hash entries),
+which can be more efficient.  See L<perlguts> for details.
+
+=back
 
 =head1 Documentation Changes
 
 Many of the base and library pods were updated.  These
 new pods are included in section 1:
 
-=over 4
+=over
 
-=item L<perlnews>
+=item L<perldelta>
 
 This document.
 
@@ -476,10 +865,19 @@ Although not new, this has been massively updated.
 
 Several new conditions will trigger warnings that were
 silent before.  Some only affect certain platforms.
-The following new warnings and errors
-outline these:
+The following new warnings and errors outline these.
+These messages are classified as follows (listed in
+increasing order of desperation):
+
+   (W) A warning (optional).
+   (D) A deprecation (optional).
+   (S) A severe warning (mandatory).
+   (F) A fatal error (trappable).
+   (P) An internal error you should never see (trappable).
+   (X) A very fatal error (nontrappable).
+   (A) An alien error message (not generated by Perl).
 
-=over 4
+=over
 
 =item "my" variable %s masks earlier declaration in same scope
 
@@ -489,15 +887,36 @@ a typographical error.  Note that the earlier variable will still exist
 until the end of the scope or until all closure referents to it are
 destroyed.
 
+=item %s argument is not a HASH element or slice
+
+(F) The argument to delete() must be either a hash element, such as
+
+    $foo{$bar}
+    $ref->[12]->{"susie"}
+
+or a hash slice, such as
+
+    @foo{$bar, $baz, $xyzzy}
+    @{$ref->[12]}{"susie", "queue"}
+
 =item Allocation too large: %lx
 
-(X) You can't allocate more than 64K on an MSDOS machine.
+(X) You can't allocate more than 64K on an MS-DOS machine.
 
 =item Allocation too large
 
 (F) You can't allocate more than 2^31+"small amount" bytes.
 
-=item Attempt to free non-existent shared string
+=item Applying %s to %s will act on scalar(%s)
+
+(W) The pattern match (//), substitution (s///), and translation (tr///)
+operators work on scalar values.  If you apply one of them to an array
+or a hash, it will convert the array or hash to a scalar value -- the
+length of an array, or the population info of a hash -- and then work on
+that scalar value.  This is probably not what you meant to do.  See
+L<perlfunc/grep> and L<perlfunc/map> for alternatives.
+
+=item Attempt to free nonexistent shared string
 
 (P) Perl maintains a reference counted internal table of strings to
 optimize the storage and access of hash keys and other strings.  This
@@ -510,22 +929,53 @@ that can no longer be found in the table.
 as an lvalue, which is pretty strange.  Perhaps you forgot to
 dereference it first.  See L<perlfunc/substr>.
 
-=item Unsupported function fork
+=item Can't use bareword ("%s") as %s ref while "strict refs" in use
 
-(F) Your version of executable does not support forking.
+(F) Only hard references are allowed by "strict refs".  Symbolic references
+are disallowed.  See L<perlref>.
 
-Note that under some systems, like OS/2, there may be different flavors of
-Perl executables, some of which may support fork, some not. Try changing
-the name you call Perl by to C<perl_>, C<perl__>, and so on.
+=item Cannot resolve method `%s' overloading `%s' in package `%s'
 
-=item Ill-formed logical name |%s| in prime_env_iter
+(P) Internal error trying to resolve overloading specified by a method
+name (as opposed to a subroutine reference).
 
-(W) A warning peculiar to VMS.  A logical name was encountered when preparing
-to iterate over %ENV which violates the syntactic rules governing logical
-names.  Since it cannot be translated normally, it is skipped, and will not
-appear in %ENV.  This may be a benign occurrence, as some software packages
-might directly modify logical name tables and introduce non-standard names,
-or it may indicate that a logical name table has been corrupted.
+=item Constant subroutine %s redefined
+
+(S) You redefined a subroutine which had previously been eligible for
+inlining.  See L<perlsub/"Constant Functions"> for commentary and
+workarounds.
+
+=item Constant subroutine %s undefined
+
+(S) You undefined a subroutine which had previously been eligible for
+inlining.  See L<perlsub/"Constant Functions"> for commentary and
+workarounds.
+
+=item Copy method did not return a reference
+
+(F) The method which overloads "=" is buggy. See L<overload/Copy Constructor>.
+
+=item Died
+
+(F) You passed die() an empty string (the equivalent of C<die "">) or
+you called it with no args and both C<$@> and C<$_> were empty.
+
+=item Exiting pseudo-block via %s
+
+(W) You are exiting a rather special block construct (like a sort block or
+subroutine) by unconventional means, such as a goto, or a loop control
+statement.  See L<perlfunc/sort>.
+
+=item Illegal character %s (carriage return)
+
+(F) A carriage return character was found in the input.  This is an
+error, and not a warning, because carriage return characters can break
+multi-line strings, including here documents (e.g., C<print E<lt>E<lt>EOF;>).
+
+=item Illegal switch in PERL5OPT: %s
+
+(X) The PERL5OPT environment variable may only be used to set the
+following switches: B<-[DIMUdmw]>.
 
 =item Integer overflow in hex number
 
@@ -539,6 +989,13 @@ architecture. On a 32-bit architecture the largest hex literal is
 architecture. On a 32-bit architecture the largest octal literal is
 037777777777.
 
+=item Name "%s::%s" used only once: possible typo
+
+(W) Typographical errors often show up as unique variable names.
+If you had a good reason for having a unique name, then just mention
+it again somehow to suppress the message (the C<use vars> pragma is
+provided for just this purpose).
+
 =item Null picture in formline
 
 (F) The first argument to formline must be a valid format picture
@@ -572,41 +1029,166 @@ a possibility to shut down by trapping this error is granted.
 
 =item Possible attempt to put comments in qw() list
 
-(W) You probably wrote something like this:
+(W) qw() lists contain items separated by whitespace; as with literal
+strings, comment characters are not ignored, but are instead treated
+as literal data.  (You may have used different delimiters than the
+exclamation marks parentheses shown here; braces are also frequently
+used.)
 
-    qw( a # a comment
+You probably wrote something like this:
+
+    @list = qw(
+        a # a comment
         b # another comment
-      ) ;
+    );
 
 when you should have written this:
 
-    qw( a
+    @list = qw(
+        a
         b
-      ) ;
+    );
+
+If you really want comments, build your list the
+old-fashioned way, with quotes and commas:
+
+    @list = (
+        'a',    # a comment
+        'b',    # another comment
+    );
 
 =item Possible attempt to separate words with commas
 
-(W) You probably wrote something like this:
+(W) qw() lists contain items separated by whitespace; therefore commas
+aren't needed to separate the items. (You may have used different
+delimiters than the parentheses shown here; braces are also frequently
+used.)
 
-    qw( a, b, c );
+You probably wrote something like this:
 
-when you should have written this:
+    qw! a, b, c !;
+
+which puts literal commas into some of the list items.  Write it without
+commas if you don't want them to appear in your data:
+
+    qw! a b c !;
+
+=item Scalar value @%s{%s} better written as $%s{%s}
+
+(W) You've used a hash slice (indicated by @) to select a single element of
+a hash.  Generally it's better to ask for a scalar value (indicated by $).
+The difference is that C<$foo{&bar}> always behaves like a scalar, both when
+assigning to it and when evaluating its argument, while C<@foo{&bar}> behaves
+like a list when you assign to it, and provides a list context to its
+subscript, which can do weird things if you're expecting only one subscript.
+
+=item Stub found while resolving method `%s' overloading `%s' in package `%s'
+
+(P) Overloading resolution over @ISA tree may be broken by importing stubs.
+Stubs should never be implicitely created, but explicit calls to C<can>
+may break this.
 
-    qw( a b c );
+=item Too late for "B<-T>" option
+
+(X) The #! line (or local equivalent) in a Perl script contains the
+B<-T> option, but Perl was not invoked with B<-T> in its argument
+list.  This is an error because, by the time Perl discovers a B<-T> in
+a script, it's too late to properly taint everything from the
+environment.  So Perl gives up.
 
 =item untie attempted while %d inner references still exist
 
 (W) A copy of the object returned from C<tie> (or C<tied>) was still
 valid when C<untie> was called.
 
-=item Got an error from DosAllocMem:
+=item Unrecognized character %s
+
+(F) The Perl parser has no idea what to do with the specified character
+in your Perl script (or eval).  Perhaps you tried to run a compressed
+script, a binary program, or a directory as a Perl program.
+
+=item Unsupported function fork
+
+(F) Your version of executable does not support forking.
+
+Note that under some systems, like OS/2, there may be different flavors of
+Perl executables, some of which may support fork, some not. Try changing
+the name you call Perl by to C<perl_>, C<perl__>, and so on.
+
+=item Value of %s can be "0"; test with defined()
+
+(W) In a conditional expression, you used <HANDLE>, <*> (glob), C<each()>,
+or C<readdir()> as a boolean value.  Each of these constructs can return a
+value of "0"; that would make the conditional expression false, which is
+probably not what you intended.  When using these constructs in conditional
+expressions, test their values with the C<defined> operator.
+
+=item Variable "%s" may be unavailable
+
+(W) An inner (nested) I<anonymous> subroutine is inside a I<named>
+subroutine, and outside that is another subroutine; and the anonymous
+(innermost) subroutine is referencing a lexical variable defined in
+the outermost subroutine.  For example:
+
+   sub outermost { my $a; sub middle { sub { $a } } }
+
+If the anonymous subroutine is called or referenced (directly or
+indirectly) from the outermost subroutine, it will share the variable
+as you would expect.  But if the anonymous subroutine is called or
+referenced when the outermost subroutine is not active, it will see
+the value of the shared variable as it was before and during the
+*first* call to the outermost subroutine, which is probably not what
+you want.
+
+In these circumstances, it is usually best to make the middle
+subroutine anonymous, using the C<sub {}> syntax.  Perl has specific
+support for shared variables in nested anonymous subroutines; a named
+subroutine in between interferes with this feature.
+
+=item Variable "%s" will not stay shared
+
+(W) An inner (nested) I<named> subroutine is referencing a lexical
+variable defined in an outer subroutine.
+
+When the inner subroutine is called, it will probably see the value of
+the outer subroutine's variable as it was before and during the
+*first* call to the outer subroutine; in this case, after the first
+call to the outer subroutine is complete, the inner and outer
+subroutines will no longer share a common value for the variable.  In
+other words, the variable will no longer be shared.
+
+Furthermore, if the outer subroutine is anonymous and references a
+lexical variable outside itself, then the outer and inner subroutines
+will I<never> share the given variable.
+
+This problem can usually be solved by making the inner subroutine
+anonymous, using the C<sub {}> syntax.  When inner anonymous subs that
+reference variables in outer subroutines are called or referenced,
+they are automatically rebound to the current values of such
+variables.
+
+=item Warning: something's wrong
+
+(W) You passed warn() an empty string (the equivalent of C<warn "">) or
+you called it with no args and C<$_> was empty.
+
+=item Ill-formed logical name |%s| in prime_env_iter
+
+(W) A warning peculiar to VMS.  A logical name was encountered when preparing
+to iterate over %ENV which violates the syntactic rules governing logical
+names.  Since it cannot be translated normally, it is skipped, and will not
+appear in %ENV.  This may be a benign occurrence, as some software packages
+might directly modify logical name tables and introduce nonstandard names,
+or it may indicate that a logical name table has been corrupted.
+
+=item Got an error from DosAllocMem
 
-(P) An error peculiar to OS/2. Most probably you use an obsolete version
-of Perl, and should not happen anyway.
+(P) An error peculiar to OS/2.  Most probably you're using an obsolete
+version of Perl, and this should not happen anyway.
 
 =item Malformed PERLLIB_PREFIX
 
-(F) An error peculiar to OS/2. PERLLIB_PREFIX should be of the form
+(F) An error peculiar to OS/2.  PERLLIB_PREFIX should be of the form
 
     prefix1;prefix2
 
@@ -614,36 +1196,38 @@ or
 
     prefix1 prefix2
 
-with non-empty prefix1 and prefix2. If C<prefix1> is indeed a prefix of
-a builtin library search path, prefix2 is substituted. The error may appear
-if components are not found, or are too long. See L<perlos2/"PERLLIB_PREFIX">.
+with nonempty prefix1 and prefix2.  If C<prefix1> is indeed a prefix
+of a builtin library search path, prefix2 is substituted.  The error
+may appear if components are not found, or are too long.  See
+"PERLLIB_PREFIX" in F<README.os2>.
 
 =item PERL_SH_DIR too long
 
 (F) An error peculiar to OS/2. PERL_SH_DIR is the directory to find the
-C<sh>-shell in. See L<perlos2/"PERL_SH_DIR">.
+C<sh>-shell in.  See "PERL_SH_DIR" in F<README.os2>.
 
 =item Process terminated by SIG%s
 
 (W) This is a standard message issued by OS/2 applications, while *nix
-applications die in silence. It is considered a feature of the OS/2
-port. One can easily disable this by appropriate sighandlers, see
-L<perlipc/"Signals">.  See L<perlos2/"Process terminated by SIGTERM/SIGINT">.
+applications die in silence.  It is considered a feature of the OS/2
+port.  One can easily disable this by appropriate sighandlers, see
+L<perlipc/"Signals">.  See also "Process terminated by SIGTERM/SIGINT"
+in F<README.os2>.
 
 =back
 
 =head1 BUGS
 
-If you find what you think is a bug, you might check the headers
-of recently posted articles 
-in the comp.lang.perl.misc newsgroup.  There may also be
-information at http://www.perl.com/perl/, the Perl Home Page.
+If you find what you think is a bug, you might check the headers of
+recently posted articles in the comp.lang.perl.misc newsgroup.
+There may also be information at http://www.perl.com/perl/, the Perl
+Home Page.
 
 If you believe you have an unreported bug, please run the B<perlbug>
-program included with your release.  Make sure you trim your bug
-down to a tiny but sufficient test case.  Your bug report, along
-with the output of C<perl -V>, will be sent off to perlbug@perl.com
-to be analysed by the Perl porting team.
+program included with your release.  Make sure you trim your bug down
+to a tiny but sufficient test case.  Your bug report, along with the
+output of C<perl -V>, will be sent off to <F<perlbug@perl.com>> to be
+analysed by the Perl porting team.
 
 =head1 SEE ALSO
 
@@ -663,4 +1247,4 @@ Constructed by Tom Christiansen, grabbing material with permission
 from innumerable contributors, with kibitzing by more than a few Perl
 porters.
 
-Last update: Tue Jan 14 14:03:02 EST 1997
+Last update: Sat Mar  8 19:51:26 EST 1997