Stories
Slash Boxes
Comments

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Journal of dc2000 (3250)

Wednesday September 18, 2002
05:14 PM

find docs evolving

[ #7816 ]

The File::Find docs said:

use File::Find;
find(\&wanted, '/foo','/bar');
sub wanted { ... }

The number of times I have found code which is meant to search one directory but
includes a bogus second dir argument is astonishing.

Likewise, I've encountered instances of multiple invocations of File::Find to search
more than two directories.

find(\&wanted, '/foo','/bar');
find(\&wanted, '/foo2','/bar2');

When I've been able to ask the author why they appended a second dir argument,
or limited themselves at two dir arguments, they've proudly pointed to their due diligence
of RTFMing the standard docs SYNOPSIS which show File::Find used with
two and only two directory arguments.

So I am pleased that the v5.8.0 docs for File::Find show a more generic:

use File::Find;
find(\&wanted, @directories_to_seach);
sub wanted { ... }

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Even more confusing is calling the callback "wanted()". My initial reaction on seeing that is thinking "wanted() needs to return a boolean", and just the other day I helped someone on IRC with that exact same conclusion.
    --

    --
    xoa