Finalize change #4232.
[p5sagit/p5-mst-13.2.git] / lib / File / Find.pm
index 67abf60..28e2e90 100644 (file)
@@ -22,10 +22,10 @@ finddepth - traverse a directory structure depth-first
 =head1 DESCRIPTION
 
 The first argument to find() is either a hash reference describing the
-operations to be performed for each file, or a code reference.  If it
-is a hash reference, then the value for the key C<wanted> should be a
-code reference.  This code reference is called I<the wanted()
-function> below.
+operations to be performed for each file, a code reference, or a string
+that contains a subroutine name.  If it is a hash reference, then the
+value for the key C<wanted> should be a code reference.  This code
+reference is called I<the wanted() function> below.
 
 Currently the only other supported key for the above hash is
 C<bydepth>, in presense of which the walk over directories is
@@ -130,6 +130,8 @@ sub find_opt {
                warn "Can't cd to $dir: $!\n";
            }
        }
+    }
+    continue {
        chdir $cwd;
     }
 }
@@ -168,6 +170,7 @@ sub finddir {
 
                # Get link count and check for directoriness.
 
+               $_ = "" if (!defined($_));
                ($dev,$ino,$mode,$nlink) = ($Is_VMS ? stat($_) : lstat($_));
                    # unless ($nlink || $dont_use_nlink);
 
@@ -194,7 +197,7 @@ sub finddir {
 
 sub wrap_wanted {
   my $wanted = shift;
-  defined &$wanted ? {wanted => $wanted} : $wanted;
+  ref($wanted) eq 'HASH' ? $wanted : { wanted => $wanted };
 }
 
 sub find {
@@ -202,7 +205,7 @@ sub find {
   find_opt(wrap_wanted($wanted), @_);
 }
 
-sub find_depth {
+sub finddepth {
   my $wanted = wrap_wanted(shift);
   $wanted->{bydepth} = 1;
   find_opt($wanted, @_);