From: Mark-Jason Dominus Date: Thu, 22 Jan 2004 09:30:58 +0000 (-0500) Subject: Re: Doc patches for File::Find X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6eb87ff8bf4b0fb28bd1498a03b1502cf11429d2;p=p5sagit%2Fp5-mst-13.2.git Re: Doc patches for File::Find Message-Id: <20040122143058.29226.qmail@plover.com> Better document the fact that neither find() nor finddepth() do a breath-first search. p4raw-id: //depot/perl@22207 --- diff --git a/lib/File/Find.pm b/lib/File/Find.pm index f9fb16b..c81c02e 100644 --- a/lib/File/Find.pm +++ b/lib/File/Find.pm @@ -44,21 +44,23 @@ but have subtle differences. find(\&wanted, @directories); find(\%options, @directories); -C does a breadth-first search over the given C<@directories> in the -order they are given. In essence, it works from the top down. - -For each file or directory found, the C<&wanted> subroutine is called, -with the return code ignored. (See below for details on how to use -the C<&wanted> function). Additionally, for each directory found, -it will go into that directory and continue the search. +C does a depth-first search over the given C<@directories> in +the order they are given. For each file or directory found, it calls +the C<&wanted> subroutine. (See below for details on how to use the +C<&wanted> function). Additionally, for each directory found, it will +C into that directory and continue the search, invoking the +C<&wanted> function on each file or subdirectory in the directory. =item B finddepth(\&wanted, @directories); finddepth(\%options, @directories); -C works just like C except it does a depth-first search. -It works from the bottom of the directory tree up. +C works just like C except that is invokes the +C<&wanted> function for a directory I invoking it for the +directory's contents. It does a postorder traversal instead of a +preorder traversal, working from the bottom of the directory tree up +where C works from the top of the tree down. =back @@ -388,6 +390,12 @@ volume actually maintains its own "Desktop Folder" directory. =back +=head1 BUGS AND CAVEATS + +Despite the name of the C function, both C and +C perform a depth-first search of the directory +hierarchy. + =head1 HISTORY File::Find used to produce incorrect results if called recursively.