Fix newSVrv so sv_setref_foo work better:
[p5sagit/p5-mst-13.2.git] / pod / perldelta.pod
index 48c04b3..7400940 100644 (file)
@@ -10,14 +10,21 @@ this one.
 
 =head1 Supported Environments
 
-Perl5.004 builds out of the box on Unix, Plan9, LynxOS, VMS, OS/2,
-QNX, AmigaOS, and Windows NT; once built on Windows NT, Perl runs
-on Windows 95 as well.
+Perl5.004 builds out of the box on Unix, Plan 9, LynxOS, VMS, OS/2,
+QNX, AmigaOS, and Windows NT.  Perl runs on Windows 95 as well, but it
+cannot be built there, for lack of a reasonable command interpreter.
 
 =head1 Core Changes
 
-Most importantly, many bugs were fixed.  See the F<Changes>
-file in the distribution for details.
+Most importantly, many bugs were fixed, including several security
+problems.  See the F<Changes> file in the distribution for details.
+
+=head2 List assignment to %ENV works
+
+C<%ENV = ()> and C<%ENV = @list> now work as expected (except on VMS
+where it generates a fatal error).
+
+=head2 "Can't locate Foo.pm in @INC" error now lists @INC
 
 =head2 Compilation option: Binary compatibility with 5.003
 
@@ -36,7 +43,7 @@ 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 Limitations on B<-M>, and C<-m>, and B<-T> options
+=head2 Limitations on B<-M>, B<-m>, and B<-T> options
 
 The C<-M> and C<-m> options are no longer allowed on the C<#!> line of
 a script.  If a script needs a module, it should invoke it with the
@@ -72,7 +79,7 @@ your scripts.
 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()>).
+(e.g. C<Foo-E<gt>bar()> or C<$obj-E<gt>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
@@ -84,6 +91,13 @@ 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 Previously deprecated %OVERLOAD is no longer usable
+
+Using %OVERLOAD to define overloading was deprecated in 5.003.
+Overloading is now defined using the overload pragma. %OVERLOAD is
+still used internally but should not be used by Perl scripts. See
+L<overload> for more details.
+
 =head2 Subroutine arguments created only when they're modified
 
 In Perl 5.004, nonexistent array and hash elements used as subroutine
@@ -92,9 +106,9 @@ 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.
+Perl versions 5.000 and 5.001 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:
 
@@ -133,6 +147,13 @@ because at least two widely-used modules depend on the old meaning of
 old (broken) way inside strings; but it generates this message as a
 warning.  And in Perl 5.005, this special treatment will cease.
 
+=head2 Fixed localization of $<digit>, $&, etc.
+
+Perl versions before 5.004 did not always properly localize the
+regex-related special variables.  Perl 5.004 does localize them, as
+the documentation has always said it should.  This may result in $1,
+$2, etc. no longer being set where existing programs use them.
+
 =head2 No resetting of $. on implicit close
 
 The documentation for Perl 5.0 has always stated that C<$.> is I<not>
@@ -158,6 +179,33 @@ previously-working script to now fail -- which should be construed
 as a blessing, since that indicates a potentially-serious security
 hole was just plugged.
 
+The new restrictions when tainting include:
+
+=over
+
+=item No glob() or <*>
+
+These operators may spawn the C shell (csh), which cannot be made
+safe.  This restriction will be lifted in a future version of Perl
+when globbing is implemented without the use of an external program.
+
+=item No spawning if tainted $CDPATH, $ENV, $BASH_ENV
+
+These environment variables may alter the behavior of spawned programs
+(especially shells) in ways that subvert security.  So now they are
+treated as dangerous, in the manner of $IFS and $PATH.
+
+=item No spawning if tainted $TERM doesn't look like a terminal name
+
+Some termcap libraries do unsafe things with $TERM.  However, it would be
+unnecessarily harsh to treat all $TERM values as unsafe, since only shell
+metacharacters can cause trouble in $TERM.  So a tainted $TERM is
+considered to be safe if it contains only alphanumerics, underscores,
+dashes, and colons, and unsafe if it contains other characters (including
+whitespace).
+
+=back
+
 =head2 New Opcode module and revised Safe module
 
 A new Opcode module supports the creation, manipulation and
@@ -182,8 +230,8 @@ 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.
 
-In harmony with this change, C<*GLOB{FILEHANDLE}> is now a
-backward-compatible synonym for C<*STDOUT{IO}>.
+In harmony with this change, C<*GLOB{FILEHANDLE}> is now just a
+backward-compatible synonym for C<*GLOB{IO}>.
 
 =head2 Internal change: PerlIO abstraction interface
 
@@ -201,11 +249,11 @@ A subroutine reference may now be suffixed with an arrow and a
 (possibly empty) parameter list.  This syntax denotes a call of the
 referenced subroutine, with the given parameters (if any).
 
-This new syntax follows the pattern of C<$hashref-E<gt>{FOO}> and
-C<$aryref-E<gt>[$foo]>; now, C<&$subref($foo)> may now be written
-C<$subref-E<gt>($foo)>.  All of these arrow terms may be chained;
-thus, C<&{$table-E<gt>{FOO}}($bar)> may now be written
-C<$table-E<gt>{FOO}->($bar)>.
+This new syntax follows the pattern of S<C<$hashref-E<gt>{FOO}>> and
+S<C<$aryref-E<gt>[$foo]>>: You may now write S<C<&$subref($foo)>> as
+S<C<$subref-E<gt>($foo)>>.  All of these arrow terms may be chained;
+thus, S<C<&{$table-E<gt>{FOO}}($bar)>> may now be written
+S<C<$table-E<gt>{FOO}-E<gt>($bar)>>.
 
 =back
 
@@ -244,7 +292,7 @@ there is no C<use English> long name for this variable.
 By default, running out of memory it is not trappable.  However, if
 compiled for this, Perl may use the contents of C<$^M> as an emergency
 pool after die()ing with this message.  Suppose that your Perl were
-compiled with -DEMERGENCY_SBRK and used Perl's malloc.  Then
+compiled with -DPERL_EMERGENCY_SBRK and used Perl's malloc.  Then
 
     $^M = 'a' x (1<<16);
 
@@ -280,8 +328,8 @@ The new conversions in Perl's sprintf() are:
 
    %i  a synonym for %d
    %p  a pointer (the address of the Perl value, in hexadecimal)
-   %n  special: B<stores> into the next variable in the parameter
-        list the number of characters printed so far
+   %n  special: *stores* the number of characters output so far
+        into the next variable in the parameter list 
 
 The new flags that go between the C<%> and the conversion are:
 
@@ -354,6 +402,9 @@ provides seven bits of the total value, with the most significant
 first.  Bit eight of each byte is set, except for the last byte, in
 which bit eight is clear.
 
+If 'p' or 'P' are given undef as values, they now generate a NULL
+pointer.
+
 Both pack() and unpack() now fail when their templates contain invalid
 types.  (Invalid types used to be ignored.)
 
@@ -415,25 +466,16 @@ of course, or if you want a seed other than the default.
 Functions documented in the Camel to default to $_ now in
 fact do, and all those that do are so documented in L<perlfunc>.
 
-=item C<m//g> does not reset search position on failure
-
-The C<m//g> match iteration construct used to reset its target string's
-search position (which is visible through the C<pos> operator) when a
-match failed; as a result, the next C<m//g> match would start at the
-beginning of the string).  With Perl 5.004, the search position must be
-reset explicitly, as with C<pos $str = 0;>, or by modifying the target
-string.  This change in Perl makes it possible to chain matches together
-in conjunction with the C<\G> zero-width assertion.  See L<perlop> and
-L<perlre>.
+=item C<m//gc> does not reset search position on failure
 
-Here is an illustration of what it takes to get the old behavior:
-
-    for ( qw(this and that are not what you think you got) ) {
-        while ( /(\w*t\w*)/g ) { print "t word is: $1\n" }
-        pos = 0;  # REQUIRED FOR 5.004
-        while ( /(\w*a\w*)/g ) { print "a word is: $1\n" }
-        print "\n";
-    }
+The C<m//g> match iteration construct has always reset its target
+string's search position (which is visible through the C<pos> operator)
+when a match fails; as a result, the next C<m//g> match after a failure
+starts again at the beginning of the string.  With Perl 5.004, this
+reset may be disabled by adding the "c" (for "continue") modifier,
+i.e. C<m//gc>.  This feature, in conjunction with the C<\G> zero-width
+assertion, makes it possible to chain matches together.  See L<perlop>
+and L<perlre>.
 
 =item C<m//x> ignores whitespace before ?*+{}
 
@@ -452,16 +494,31 @@ right.  They do now.
 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:
+before (printed only zeros), but is fine now:
 
     my $i;
     foreach $i ( 1 .. 10 ) {
-       format =
+       write;
+    }
+    format =
        my i is @#
        $i
     .
+
+However, it still fails (without a warning) if the foreach is within a
+subroutine:
+
+    my $i;
+    sub foo {
+      foreach $i ( 1 .. 10 ) {
        write;
+      }
     }
+    foo;
+    format =
+       my i is @#
+       $i
+    .
 
 =back
 
@@ -599,24 +656,23 @@ possibly for cleaning up.
 
 =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
+If perl is compiled with the malloc included with the perl distribution
+(that is, if C<perl -V:d_mymalloc> is 'define') then 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.
+exit; with a value of 1, the statistics are 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
+Three new compilation flags are recognized by malloc.c.  (They have no
+effect if perl is compiled with system malloc().)
+
+=over
+
+=item -DPERL_EMERGENCY_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
@@ -665,6 +721,42 @@ 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 Support for More Operating Systems
+
+Support for the following operating systems is new in Perl 5.004.
+
+=head2 Win32
+
+Perl 5.004 now includes support for building a "native" perl under
+Windows NT, using the Microsoft Visual C++ compiler (versions 2.0
+and above) or the Borland C++ compiler (versions 5.02 and above).
+The resulting perl can be used under Windows 95 (if it
+is installed in the same directory locations as it got installed
+in Windows NT).  This port includes support for perl extension
+building tools like L<MakeMaker> and L<h2xs>, so that many extensions
+available on the Comprehensive Perl Archive Network (CPAN) can now be
+readily built under Windows NT.  See http://www.perl.com/ for more
+information on CPAN, and L<README.win32> for more details on how to
+get started with building this port.
+
+There is also support for building perl under the Cygwin32 environment.
+Cygwin32 is a set of GNU tools that make it possible to compile and run
+many UNIX programs under Windows NT by providing a mostly UNIX-like 
+interface for compilation and execution.  See L<README.cygwin32> for
+more details on this port, and how to obtain the Cygwin32 toolkit.
+
+=head2 Plan 9
+
+See L<README.plan9>.
+
+=head2 QNX
+
+See L<README.qnx>.
+
+=head2 AmigaOS
+
+See L<README.amigaos>.
+
 =head1 Pragmata
 
 Six new pragmatic modules exist:
@@ -933,6 +1025,19 @@ For example, you can now say
 
 =head1 Utility Changes
 
+=head2 pod2html
+
+=over
+
+=item Sends converted HTML to standard output
+
+The I<pod2html> utility included with Perl 5.004 is entirely new.
+By default, it sends the converted HTML to its standard output,
+instead of writing it to a file like Perl 5.003's I<pod2html> did.
+Use the B<--outfile=FILENAME> option to write to a file.
+
+=back
+
 =head2 xsubpp
 
 =over
@@ -1007,6 +1112,10 @@ new pods are included in section 1:
 
 This document.
 
+=item L<perlfaq>
+
+Frequently asked questions.
+
 =item L<perllocale>
 
 Locale support (internationalization and localization).
@@ -1019,6 +1128,11 @@ Tutorial on Perl OO programming.
 
 Perl internal IO abstraction interface.
 
+=item L<perlmodlib>
+
+Perl module library and recommended practice for module creation.
+Extracted from L<perlmod> (which is much smaller as a result).
+
 =item L<perldebug>
 
 Although not new, this has been massively updated.
@@ -1049,7 +1163,7 @@ increasing order of desperation):
 
 =item "my" variable %s masks earlier declaration in same scope
 
-(S) A lexical variable has been redeclared in the same scope, effectively
+(W) A lexical variable has been redeclared in the same scope, effectively
 eliminating all access to the previous instance.  This is almost always
 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
@@ -1097,6 +1211,13 @@ 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 Can't redefine active sort subroutine %s
+
+(F) Perl optimizes the internal handling of sort subroutines and keeps
+pointers into them.  You tried to redefine one such sort subroutine when it
+was currently active, which is not allowed.  If you really want to do
+this, you should write C<sort { &func } @x> instead of C<sort func @x>.
+
 =item Can't use bareword ("%s") as %s ref while "strict refs" in use
 
 (F) Only hard references are allowed by "strict refs".  Symbolic references
@@ -1462,4 +1583,4 @@ Constructed by Tom Christiansen, grabbing material with permission
 from innumerable contributors, with kibitzing by more than a few Perl
 porters.
 
-Last update: Sat Mar  8 19:51:26 EST 1997
+Last update: Wed May 14 11:14:09 EDT 1997