Patch for perl.pod
[p5sagit/p5-mst-13.2.git] / pod / perldelta.pod
index bfdf903..46bd59b 100644 (file)
@@ -27,12 +27,29 @@ might have symbol conflicts if you embed Perl in another application,
 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 Subroutine arguments created only when they're modified
 
-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.
+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.
 
@@ -42,13 +59,49 @@ 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 Internal Change: FileHandle Deprecated
+=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 re-opened with no intervening
+call to C<close>.  Due to a bug, perl versions 5.000 through 5.0003
+I<did> reset C<$.> under that circumstance; Perl 5.004 does not.
+
+=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 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
 
@@ -99,8 +152,8 @@ 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
 
@@ -198,6 +251,19 @@ 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
@@ -213,10 +279,17 @@ 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
+esacping repeat modifier 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.
+Prior to the 5.004 release, nested anonymous functions didn't work
+right.  They do now.
 
 =item formats work right on changing lexicals
 
@@ -232,7 +305,7 @@ before, and is fine now:
        $i
     .
        write;
-    } 
+    }
 
 =back
 
@@ -245,7 +318,7 @@ are inherited by all other classes:
 
 =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:
@@ -298,9 +371,9 @@ 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; 
+    sub TIEHANDLE {
+       print "<shout>\n";
+       my $i;
        return bless \$i, shift;
     }
 
@@ -310,29 +383,46 @@ 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++; 
+    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; 
-       return "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
 
 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 { 
+    sub DESTROY {
        print "</shout>\n";
     }
 
@@ -340,8 +430,15 @@ possibly for cleaning up.
 
 =head2 Malloc Enhancements
 
-If perl's malloc() is used, you can print memory statistics at runtime
-by running Perl thusly:
+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
 
@@ -350,11 +447,6 @@ 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.)
 
-In addition, three new compilation flags are recognized by malloc.c.
-(They have no effect if perl is compiled with system malloc().)
-
-=over
-
 =item -DEMERGENCY_SBRK
 
 If this macro is defined, running out of memory need not be a fatal
@@ -402,7 +494,7 @@ 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 re-allocated.
+same hash, the hash keys never have to be reallocated.
 
 =head1 Pragmata
 
@@ -472,7 +564,7 @@ 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_ASYNC O_DEFER O_DSYNC O_FSYNC O_SYNC
     O_EXLOCK O_SHLOCK
 
 These constants are intended for use with the Perl operators sysopen()
@@ -721,7 +813,7 @@ 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):
 
@@ -880,7 +972,7 @@ used.)
 
 You probably wrote something like this:
 
-    @list = qw( 
+    @list = qw(
         a # a comment
         b # another comment
     );
@@ -888,7 +980,7 @@ You probably wrote something like this:
 when you should have written this:
 
     @list = qw(
-        a 
+        a
         b
     );
 
@@ -907,7 +999,7 @@ aren't needed to separate the items. (You may have used different
 delimiters than the parentheses shown here; braces are also frequently
 used.)
 
-You probably wrote something like this: 
+You probably wrote something like this:
 
     qw! a, b, c !;
 
@@ -1028,10 +1120,10 @@ 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 F<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
 
@@ -1051,4 +1143,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