Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Problem with File::DirWalk and Active Perl

by kcott (Archbishop)
on Mar 15, 2012 at 22:43 UTC ( [id://959881]=note: print w/replies, xml ) Need Help??


in reply to Problem with File::DirWalk and Active Perl

The first line of code you show (from File::DirWalk) leaped out at me as being wrong.

opendir my $dirh, $path || return FAILED;

To avoid operator precedence problems (see perlop), this should be written as:

opendir my $dirh, $path or return FAILED;

or

opendir(my $dirh, $path) || return FAILED;

Also note that this provides no feedback on why opendir failed.

I thought I'd give your code a try and installed File::DirWalk. During the make test phase, I received the same errors (at the same line numbers) you're reporting but the output showed testing was successful.

t/1.t .. 1/3 readdir() attempted on invalid dirhandle at /Users/ken/. +cpan/build/File-DirWalk-0.3-mt7jiA/blib/lib/File/DirWalk.pm line 100. closedir() attempted on invalid dirhandle at /Users/ken/.cpan/build/F +ile-DirWalk-0.3-mt7jiA/blib/lib/File/DirWalk.pm line 117. t/1.t .. ok All tests successful.

At this point, I decided not to test your code with a module which did not install cleanly.

I had a look at File-DirWalk reviews. These are generally negative.

I'd suggest using File::Find. Callbacks are available through The wanted function. It's also a core module so no installation is required.

Not directly related to your problem but I'd recommend taking a look at File::Spec. This is also a core module and provides functions which will allow you to avoid hand-crafting non-portable code such as:

$currdir = dir(split("/[\\\/]", $currdir));

-- Ken

Replies are listed 'Best First'.
Re^2: Problem with File::DirWalk and Active Perl
by Anonymous Monk on Mar 16, 2012 at 16:10 UTC
    Thanks, fellas ... got it now and changed to File::Find with much more sanguine results. phlpittsny

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-04-19 04:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found