in reply to Re: Perl file handles
in thread Perl file handles

I appreciate the response, and I guess I did not catch the mention of using close(DATA). All CB showed me was "All is quiet".

That being said, the above code and it doesn't work.

I use :

system qq{$Command "$0" >nul 2>&1};

close(DATA);

Same as usual. File cannot be deleted or renamed.

Replies are listed 'Best First'.
Re^3: Perl file handles
by ikegami (Patriarch) on Mar 06, 2009 at 19:04 UTC
    Wrong order. Closing DATA after the child has finished running will have little effect on the child.
      Ah! that did work.

      So, the idea is to close the DATA handle BEFORE you spawn the child, so the handle is not passed to it in the first place?

      I was thinking you closed the handle between the child being spawned and the parent process closing. But then I assume the child would still have a pointer back to the originating file?

      I am still unclear about how threading in perl works.

        No, the idea is to close the DATA handle BEFORE you spawn the child in order to release the lock BEFORE the child tries to delete the file.

        I am still unclear about how threading in perl works.

        I don't see how this is relevant to this conversation.