Can you characterize your bug a little more specifically? File::Find works perfectly for me with respect to symlinks, whether they point somewhere or not. In fact, I often use File::Find to locate dangling symlinks:
use File::Finder; # my wrapper around File::Find
@nowhere = File::Finder->eval(sub { -l and not -e })->in($ENV{HOME});
So, what is your brokenness?
| [reply] [d/l] |
Apologies for the delay, had to fetch File::Finder as it's not in the core perl and I wanted to have both methods detailed in the script.
Here's a testcase:
#!/usr/bin/perl
# pragmata
use warnings;
use strict;
use integer;
# Modules
use File::Finder; # merlyns wrapper around File::Find
use File::Find; # core module
# Prototypes
sub wanted;
sub dangling_symlink_handler;
sub goFinder($);
sub goFind($);
#
my $pathname = shift; chomp ($pathname);
print "Querying Perhaps Broken Symlink Handling For $pathname \n";
#
# generic find should grab anything and get anything that is valid
print "call goFinder:\n";
goFinder($pathname);
print "done goFinder:\n";
print "call goFind:\n";
goFind($pathname);
print "done goFind:\n";
###################################################################
sub goFinder($){
my $searchpath = shift (@_);
my @goodlinks = ();
my @badlinks = ();
print "in goFinder($searchpath)\n";
# Slightly modified merlynish example
@goodlinks = File::Finder->eval(sub { -l and -e })->in($search
+path);
foreach (@goodlinks) {
print "File::Finder Found good link:$_"."\n";
}
@badlinks = File::Finder->eval(sub { -l and not -e })->in($sea
+rchpath);
foreach (@badlinks) {
print "File::Finder Found bad link:$_"."\n";
}
print "exiting goFinder($searchpath)\n";
}
sub goFind($) {
my $searchpath = shift (@_);
print "in getFileList($searchpath)\n";
find( { wanted => \&wanted, no_chdir => 1, dangling_symlinks =
+> \&dangling_symlink_handler }, $searchpath);
print "exiting getFileList($searchpath)\n";
}
sub wanted {
print "\tWanted Sees This:\n\t".$File::Find::name."\n";
}
sub dangling_symlink_handler {
print "\tDangling Symlink Handler Sees This:\n\t".$File::Find:
+:name."\n";
}
So there it is, the stock File::Find find function doesn't call the dangling_symlink_handler as advertised (or as I read it's advertisment) and your File::Finder module finds stuff just fine, either it works around this behavior properly or I'm misunderstanding its behavior. As File::Finder is not a core module, I hadn't used it up 'til now thus avoiding convincing my superiors to allowing its installation.
| [reply] [d/l] |
Ah, so that isn't a problem so much with File::Find in general, but with the recently-bolted-on dangling-symlink-handler thingy, which I've never used.
(Reading docs quickly...)
Hmm. Since it's immediately after the "follow" group of options, I bet it only kicks in when follow is enabled, which you haven't. However, I would then argue that it's a bit of a doc bug. Try rerunning your test with follow set to 1.
| [reply] |
I'll put together a demonstration case of the failure, but with both the AIX and Gentoo Linux version of perl the dangling symlink handler never gets called for me.
This is with perl versions 5.8.5 on Linux and 5.8.0 on AIX 5.
| [reply] |