This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
support for C<exists &func> (from Spider Boardman)
[perl5.git] / pod / perldelta.pod
index d070aa2..cd596e2 100644 (file)
@@ -425,20 +425,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, "@_"
@@ -812,6 +837,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
@@ -1045,7 +1074,10 @@ 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 continues to be set to text mode.
+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]
 
@@ -1089,6 +1121,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
@@ -1567,6 +1603,11 @@ 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 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.