Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: What's broken in Perl 5?

by fraterm (Scribe)
on May 02, 2005 at 07:48 UTC ( [id://453160]=note: print w/replies, xml ) Need Help??


in reply to What's broken in Perl 5?

The File::Find as available in the core modules has some brokenness with regard to advertised behavior with broken or more accurately dangling symlinks. Try getting a handler to be called when one is encountered... That's the only thing that has bitten me lately though.

Edit: added a space after the cpan link... arrgh.

Squibbie Pooh Ski Doo.

Replies are listed 'Best First'.
Re^2: What's broken in Perl 5?
by merlyn (Sage) on May 02, 2005 at 14:16 UTC
    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?

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

      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.

      Squibbie Pooh Ski Doo.
        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.

        -- Randal L. Schwartz, Perl hacker
        Be sure to read my standard disclaimer if this is a 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.

      Squibbie Pooh Ski Doo.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://453160]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2024-04-26 06:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found