in reply to Re^2: What's broken in Perl 5?
in thread What's broken in Perl 5?
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: What's broken in Perl 5?
by merlyn (Sage) on May 05, 2005 at 10:55 UTC | |
by fraterm (Scribe) on May 05, 2005 at 14:24 UTC |