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 |