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

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
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/ 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/ line 318. closedir() attempted on invalid dirhandle PTH_DH at c:\trunk\3pty\perl +\lib/File/Copy/ 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

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

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (1)
As of 2022-05-21 21:07 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (78 votes). Check out past polls.