Ok, this is what I get for assuming other people can write code. mr_mischief was correct, the calls to pathrm were not using the second argument to force the call to pathempty. My bad for not re-reading the docs. Makes me wonder how this ever worked, as the return value of pathrm was not being checked so every call to delete a directory was silently failing and being ignored. Now that I'm done chasing that red herring, perhaps I can solve the original problem.

This one server has been throwing the error:
closedir() attempted on invalid dirhandle PTH_DH at C:\Work\trunk\3pty\perl\lib/File/Copy/Recursive.pm line 318.

After some extensive time in the debugger, here's what seems to be happening:

pathrmdir calls pathempty, which opens the directory and iterates over the items, calling unlink for files and pathrmdir for directories. At some point it hits a directory, the sole content of which is an empty directory . pathrmdir calls pathempty which calls pathrmdir which calls pathempty, which does nothing and returns. pathrmdir calls rmdir on the empty directory and returns. Back in pathempty it tries to close the dir handle and exits with code 9.

I think these functions need to localize the dir handle it's using, I'm surprised this doesn't come up more often. I have just reproduced it using the following:

For a directory that looks like this:

C:\TMP\PATHTEST |--bar |--baz
where baz is the only thing in bar, and baz is empty, using this code:
perl -e "use File::Copy::Recursive qw(pathrmdir); pathrmdir('pathtest' +,1); print qq(done\n);"
the output is:
closedir() attempted on invalid dirhandle PTH_DH at c:\trunk\3pty\perl +\lib/File/Copy/Recursive.pm line 318. closedir() attempted on invalid dirhandle PTH_DH at c:\trunk\3pty\perl +\lib/File/Copy/Recursive.pm line 318. done

And that's on a different pc than the one originally showing the problem. I will try localizing the dir handle and see what happens.


In reply to Re: Perl under windows: mysteriously skipping over subroutine by UnstoppableDrew
in thread Perl under windows: mysteriously skipping over subroutine by UnstoppableDrew

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.