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


In reply to Re: Problem with File::DirWalk and Active Perl by kcott
in thread Problem with File::DirWalk and Active Perl by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.