On Wednesday, June 5, 2002, at 03:12 , James Kelty wrote:
> Hello.
>
> I am using the File::Find module from Cpan to travers some filesystems to,
> well, find a file.
> Here is my small snippet of code. Basically what is happening is that the
> sub is returning a 0 instead of the file name. What am I doing wrong?
as Michael Fowler <[EMAIL PROTECTED]> wisely noted.
> If you want a list of the found files your wanted subroutine is going to
> have to append them to some array. If you want to act on a given
> filename,
> put the code that does the action in the wanted subroutine.
>
>
> my $newConf = File::Find::find({wanted => \&wanted}, '/');
> [snip]
> sub wanted {
> /^base\\.conf\z/s &&
> return("$name");
> }
one really big version of the code we have used is:
http://www.wetware.com/drieux/pbl/misc/findModules.txt
you might use something like:
sub wanted {
if ( -d && ! -x ) { $File::Find::prune = 1 ; return }
return unless /$confName$/ ;
my $fullPath = "$File::Find::dir/$_";
push(@baseList, $fullPath); # stash for post processing after find
} # end of wanted
and try not to run from "/" - way lots of stuff you do not
want to have to look through like /dev and /proc....
hence maybe something shorter like
my @baseList;
my $confName = "base.conf";
my @dirList = qw!/tmp /Users !; # /var /usr!;
foreach my $dir (@dirList) {
print "so we start by checking :$dir:\n";
#find({ wanted => \&wanted, follow => 1, no_chdir => 1 },$dir);
find({ wanted => \&wanted, follow => 1 },$dir);
}
foreach my $bs (@baseList) {
print "well we found this $bs\n";
}
as some play around until you have the look and feel ok enough...
{ I had to put 'follow' since "/tmp" is actually a symbolic link....
ciao
drieux
---
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]