s/STOP/CHECK/ blocks
[p5sagit/p5-mst-13.2.git] / pod / perldelta.pod
index 2ea14a2..495e2ff 100644 (file)
@@ -1,6 +1,6 @@
 =head1 NAME
 
-perldelta - what's new for perl v5.6 (as of v5.005_62)
+perldelta - what's new for perl v5.6 (as of v5.005_64)
 
 =head1 DESCRIPTION
 
@@ -15,8 +15,8 @@ This document describes differences between the 5.005 release and this one.
 
 =head2 Perl Source Incompatibilities
 
-Beware that any new warnings that have been added or enhanced old
-warnings are B<not> considered incompatible changes.
+Beware that any new warnings that have been added or old ones
+that have been enhanced are B<not> considered incompatible changes.
 
 Since all new warnings must be explicitly requested via the C<-w>
 switch or the C<warnings> pragma, it is ultimately the programmer's
@@ -24,11 +24,13 @@ responsibility to ensure that warnings are enabled judiciously.
 
 =over 4
 
-=item STOP is a new keyword
+=item CHECK is a new keyword
 
-In addition to C<BEGIN>, C<INIT> and C<END>, subroutines named
-C<STOP> are now special.  They are queued up for execution at the
-end of compilation, and cannot be called directly.
+In addition to C<BEGIN>, C<INIT>, C<END>, C<DESTROY> and C<AUTOLOAD>,
+subroutines named C<CHECK> are now special.  These are queued up during
+compilation and behave similar to END blocks, except they are called at
+the end of compilation rather than at the end of execution.  They cannot
+be called directly.
 
 =item Treatment of list slices of undef has changed
 
@@ -95,9 +97,9 @@ but still allowed it.
 
 In Perl 5.6 and later, C<"$$1"> always means C<"${$1}">.
 
-=item values(%h) and C<\(%h)> operate on aliases to values, not copies
+=item delete(), values() and C<\(%h)> operate on aliases to values, not copies
 
-each(), values() and hashes in a list context return the actual
+delete(), each(), values() and hashes in a list context return the actual
 values in the hash, instead of copies (as they used to in earlier
 versions).  Typical idioms for using these constructs copy the
 returned values, but this can make a significant difference when
@@ -147,6 +149,14 @@ needs to be written with additional parentheses now:
 
 The behavior remains unaffected when C<not> is not followed by parentheses.
 
+=item Semantics of bareword prototype C<(*)> have changed
+
+Arguments prototyped as C<*> will now be visible within the subroutine
+as either a simple scalar or as a reference to a typeglob.  Perl 5.005
+always coerced simple scalar arguments to a typeglob, which wasn't useful
+in situations where the subroutine must distinguish between a simple
+scalar and a typeglob.  See L<perlsub/Prototypes>.
+
 =back
 
 =head2 C Source Incompatibilities
@@ -423,20 +433,45 @@ This is rather similar to how the arrow may be omitted from
 C<$foo[10]->{'foo'}>.  Note however, that the arrow is still
 required for C<foo(10)->('bar')>.
 
+=head2 exists() is supported on subroutine names
+
+The exists() builtin now works on subroutine names.  A subroutine
+is considered to exist if it has been declared (even if implicitly).
+See L<perlfunc/exists> for examples.
+
+=head2 exists() and delete() are supported on array elements
+
+The exists() and delete() builtins now work on simple arrays as well.
+The behavior is similar to that on hash elements.
+
+exists() can be used to check whether an array element has been
+initialized without autovivifying it.  If the array is tied, the
+EXISTS() method in the corresponding tied package will be invoked.
+
+delete() may be used to remove an element from the array and return
+it.  The array element at that position returns to its unintialized
+state, so that testing for the same element with exists() will return
+false.  If the element happens to be the one at the end, the size of
+the array also shrinks by one.  If the array is tied, the DELETE() method
+in the corresponding tied package will be invoked.
+
+See L<perlfunc/exists> and L<perlfunc/delete> for examples.
+
 =head2 syswrite() ease-of-use
 
 The length argument of C<syswrite()> has become optional.
 
-=head2 Filehandles can be autovivified
+=head2 File and directory handles can be autovivified
 
 Similar to how constructs such as C<$x->[0]> autovivify a reference,
-open() now autovivifies a filehandle if the first argument is an
-uninitialized variable.  This allows the constructs C<open(my $fh, ...)> and
-C<open(local $fh,...)> to be used to create filehandles that will
-conveniently be closed automatically when the scope ends, provided there
-are no other references to them.  This largely eliminates the need for
-typeglobs when opening filehandles that must be passed around, as in the
-following example:
+handle constructors (open(), opendir(), pipe(), socketpair(), sysopen(),
+socket(), and accept()) now autovivify a file or directory handle
+if the handle passed to them is an uninitialized scalar variable.  This
+allows the constructs such as C<open(my $fh, ...)> and C<open(local $fh,...)>
+to be used to create filehandles that will conveniently be closed
+automatically when the scope ends, provided there are no other references
+to them.  This largely eliminates the need for typeglobs when opening
+filehandles that must be passed around, as in the following example:
 
     sub myopen {
         open my $fh, "@_"
@@ -509,7 +544,9 @@ start losing precision (their lower digits).
 If you have filesystems that support "large files" (files larger than
 2 gigabytes), you may now also be able to create and access them from
 Perl.  You have to use Configure -Duselargefiles.  Turning on the
-large file support turns on also the 64-bit support, for obvious reasons.
+large file support turns on also the 64-bit support on many platforms.
+Beware that unless your filesystem also supports "sparse files" seeking
+to umpteen petabytes may be unadvisable.
 
 Note that in addition to requiring a proper file system to do large
 files you may also need to adjust your per-process (or your
@@ -532,13 +569,13 @@ process resource usage limits, including the maximum filesize limit.
 =head2 Long doubles
 
 In some systems you may be able to use long doubles to enhance the
-range of precision of your double precision floating point numbers
+range and precision of your double precision floating point numbers
 (that is, Perl's numbers).  Use Configure -Duselongdouble to enable
 this support (if it is available).
 
 =head2 "more bits"
 
-You can Configure -Dusemorebits to turn on both the 64-bit support
+You can "Configure -Dusemorebits" to turn on both the 64-bit support
 and the long double support.
 
 =head2 Enhanced support for sort() subroutines
@@ -691,13 +728,6 @@ BEGIN blocks are executed under such conditions, this variable
 enables perl code to determine whether actions that make sense
 only during normal running are warranted.  See L<perlvar>.
 
-=head2 STOP blocks
-
-Arbitrary code can be queued for execution when Perl has finished
-parsing the program (i.e. when the compile phase ends) using STOP
-blocks.  These behave similar to END blocks, except for being
-called at the end of compilation rather than at the end of execution.
-
 =head2 Optional Y2K warnings
 
 If Perl is built with the cpp macro C<PERL_Y2KWARN> defined,
@@ -711,9 +741,10 @@ See L<INSTALL> and L<README.Y2K>.
 
 =head2 E<lt>HANDLEE<gt> on empty files
 
-With C<$/> set to C<undef>, slurping an empty file returns a string of
+With C<$/> set to C<undef>, "slurping" an empty file returns a string of
 zero length (instead of C<undef>, as it used to) the first time the
-HANDLE is read.  Further reads yield C<undef>.
+HANDLE is read after C<$/> is set to C<undef>.  Further reads yield
+C<undef>.
 
 This means that the following will append "foo" to an empty file (it used
 to do nothing):
@@ -780,6 +811,12 @@ on C<NEW> will return the same data as the corresponding operation
 on C<OLD>.  Formerly, it would have returned the data from the start
 of the following disk block instead.
 
+=head2 eof() has the same old magic as <>
+
+C<eof()> would return true if no attempt to read from C<E<lt>E<gt>> had
+yet been made.  C<eof()> has been changed to have a little magic of its
+own, it now opens the C<E<lt>E<gt>> files.
+
 =head2 system(), backticks and pipe open now reflect exec() failure
 
 On Unix and similar platforms, system(), qx() and open(FOO, "cmd |")
@@ -811,6 +848,10 @@ been corrected.
 When applied to a pseudo-hash element, exists() now reports whether
 the specified value exists, not merely if the key is valid.
 
+delete() now works on pseudo-hashes.  When given a pseudo-hash element
+or slice it deletes the values corresponding to the keys (but not the keys
+themselves).  See L<perlref/"Pseudo-hashes: Using an array as a hash">.
+
 =head2 C<goto &sub> and AUTOLOAD
 
 The C<goto &sub> construct works correctly when C<&sub> happens
@@ -884,7 +925,7 @@ run in compile-only mode.  Since this is typically not the expected
 behavior, END blocks are not executed anymore when the C<-c> switch
 is used.
 
-See L<STOP blocks> for how to run things when the compile phase ends.
+See L<CHECK blocks> for how to run things when the compile phase ends.
 
 =head2 Potential to leak DATA filehandles
 
@@ -1042,6 +1083,13 @@ The C<Shell> module is supported.
 Rudimentary support for building under command.com in Windows 95
 has been added.
 
+Scripts are read in binary mode by default to allow ByteLoader (and
+the filter mechanism in general) to work properly.  For compatibility,
+the DATA filehandle will be set to text mode if a carriage return is
+detected at the end of the line containing the __END__ or __DATA__
+token; if not, the DATA filehandle will be left open in binary mode.
+Earlier versions always opened the DATA filehandle in text mode.
+
 [TODO - GSAR]
 
 =head1 New tests
@@ -1084,6 +1132,10 @@ File test operators.
 
 Verify operations that access pad objects (lexicals and temporaries).
 
+=item  op/exists_sub
+
+Verify C<exists &sub> operations.
+
 =back
 
 =head1 Modules and Pragmata
@@ -1113,7 +1165,17 @@ Perl bytecode.  See L<ByteLoader>.
 
 =item constant
 
-References can now be used.  See L<constant>.
+References can now be used.
+
+The new version also allows a leading underscore in constant names, but
+disallows a double leading underscore (as in "__LINE__").  Some other names
+are disallowed or warned against, including BEGIN, END, etc.  Some names
+which were forced into main:: used to fail silently in some cases; now they're
+fatal (outside of main::) and an optional warning (inside of main::).
+The ability to detect whether a constant had been set with a given name has
+been added.
+
+See L<constant>.
 
 =item charnames
 
@@ -1134,7 +1196,8 @@ to Perl's debugging API.
 
 =item DB_File
 
-[TODO - Paul Marquess <paul.marquess@bt.com>]
+DB_File can now be built with Berkeley DB versions 1, 2 or 3.
+See C<ext/DB_File/Changes>.
 
 =item Devel::DProf
 
@@ -1198,10 +1261,12 @@ change#4135, also needs docs in module pod
 =item Fcntl
 
 More Fcntl constants added: F_SETLK64, F_SETLKW64, O_LARGEFILE for
-large (more than 4G) file access (64-bit support is not yet
-working, though, so no need to get overly excited), Free/Net/OpenBSD
-locking behaviour flags F_FLOCK, F_POSIX, Linux F_SHLCK, and
-O_ACCMODE: the mask of O_RDONLY, O_WRONLY, and O_RDWR.
+large file (more than 4GB) access Note that the O_LARGEFILE is
+automatically/transparently added to sysopen() flags if large file
+support has been configured), Free/Net/OpenBSD locking behaviour flags
+F_FLOCK, F_POSIX, Linux F_SHLCK, and O_ACCMODE: the combined mask of
+O_RDONLY, O_WRONLY, and O_RDWR.  Also SEEK_SET, SEEK_CUR, and SEEK_END
+added for one-stop shopping of the seek/sysseek constants.
 
 =item File::Compare
 
@@ -1488,11 +1553,24 @@ A tutorial on managing class data for object modules.
 
 =over 4
 
+=item "%s" variable %s masks earlier declaration in same %s
+
+(W) A "my" or "our" variable has been redeclared in the current scope or statement,
+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
+destroyed.
+
 =item "my sub" not yet implemented
 
 (F) Lexically scoped subroutines are not yet implemented.  Don't try that
 yet.
 
+=item "our" variable %s redeclared
+
+(W) You seem to have already declared the same global once before in the
+current lexical scope.
+
 =item '!' allowed only after types %s
 
 (F) The '!' is allowed in pack() and unpack() only after certain types.
@@ -1551,6 +1629,30 @@ definition ahead of the call to get proper prototype checking.  Alternatively,
 if you are certain that you're calling the function correctly, you may put
 an ampersand before the name to avoid the warning.  See L<perlsub>.
 
+=item %s argument is not a HASH or ARRAY element
+
+(F) The argument to exists() must be a hash or array element, such as:
+
+    $foo{$bar}
+    $ref->[12]->["susie"]
+
+=item %s argument is not a HASH or ARRAY element or slice
+
+(F) The argument to delete() must be either a hash or array element, such as:
+
+    $foo{$bar}
+    $ref->[12]->["susie"]
+
+or a hash or array slice, such as:
+
+    @foo[$bar, $baz, $xyzzy]
+    @{$ref->[12]}{"susie", "queue"}
+
+=item %s argument is not a subroutine name
+
+(F) The argument to exists() for C<exists &sub> must be a subroutine
+name, and not a subroutine call.  C<exists &sub()> will generate this error.
+
 =item %s package attribute may clash with future reserved word: %s
 
 (W) A lowercase attribute name was used that had a package-specific handler.
@@ -1613,6 +1715,17 @@ so it was truncated to the string shown.
 
 (P) For some reason you can't check the filesystem of the script for nosuid.
 
+=item Can't declare class for non-scalar %s in "%s"
+
+(S) Currently, only scalar variables can declared with a specific class
+qualifier in a "my" or "our" declaration.  The semantics may be extended
+for other types of variables in future.
+
+=item Can't declare %s in "%s"
+
+(F) Only scalar, array, and hash variables may be declared as "my" or
+"our" variables.  They must have ordinary identifiers as names.
+
 =item Can't ignore signal CHLD, forcing to default
 
 (W) Perl has detected that it is being run with the SIGCHLD signal
@@ -1698,6 +1811,11 @@ just use C<if (%hash) { # not empty }> for example.
 
 See Server error.
 
+=item Did you mean "local" instead of "our"?
+
+(W) Remember that "our" does not localize the declared global variable.
+You have declared it again in the same lexical scope, which seems superfluous.
+
 =item Document contains no data
 
 See Server error.
@@ -1722,6 +1840,19 @@ intended it to be a read/write filehandle, you needed to open it with
 you intended only to read from the file, use "E<lt>".  See
 L<perlfunc/open>.
 
+=item flock() on closed filehandle %s
+
+(W) The filehandle you're attempting to flock() got itself closed some
+time before now.  Check your logic flow.  flock() operates on filehandles.
+Are you attempting to call flock() on a dirhandle by the same name?
+
+=item Global symbol "%s" requires explicit package name
+
+(F) You've said "use strict vars", which indicates that all variables
+must either be lexically scoped (using "my"), declared beforehand using
+"our", or explicitly qualified to say which package the global variable
+is in (using "::").
+
 =item Hexadecimal number > 0xffffffff non-portable
 
 (W) The hexadecimal number you specified is larger than 2**32-1
@@ -1825,6 +1956,22 @@ construction, but the command was missing or blank.
 (F) The reserved syntax for lexically scoped subroutines requires that they
 have a name with which they can be found.
 
+=item No %s specified for -%c
+
+(F) The indicated command line switch needs a mandatory argument, but
+you haven't specified one.
+
+=item No package name allowed for variable %s in "our"
+
+(F) Fully qualified variable names are not allowed in "our" declarations,
+because that doesn't make much sense under existing semantics.  Such
+syntax is reserved for future extensions.
+
+=item No space allowed after -%c
+
+(F) The argument to the indicated command line switch must follow immediately
+after the switch, without intervening spaces.
+
 =item no UTC offset information; assuming local time is UTC
 
 (S) A warning peculiar to VMS.  Perl was unable to find the local
@@ -1855,6 +2002,18 @@ reference.
 (P) Failed an internal consistency check while trying to reset all weak
 references to an object.
 
+=item Parentheses missing around "%s" list
+
+(W) You said something like
+
+    my $foo, $bar = @_;
+
+when you meant
+
+    my ($foo, $bar) = @_;
+
+Remember that "my", "our" and "local" bind closer than comma.
+
 =item Possible Y2K bug: %s
 
 (W) You are concatenating the number 19 with another number, which