I'm not exactly sure what's going on in this script as I can't see what fileparse() is supposed to be doing, but I suspect that whatever it is, $file may not have been closed properly by the time your script is trying to move it. (This may or may not be the script's fault -- please keep reading)

I see that the script used to do a system() call to execute the shell command "move" directly but was revised to use File::Copy. Now, the commented lines have a time stamp suggesting that this problem has been around for a while and I have a feeling that the problem therefore isn't really related to how the move operation is executed at all.

Searching around for a bit, I find that IF the files happen to be on a network share, this has been known to just happen occasionally, because Windows. http://stackoverflow.com/questions/1167942/why-does-perls-filecopy-appear-to-silently-fail (See the bottom answer in particular, it offers a possible solution that may or may not solve your underlying problem.)

Apart from this, I don't know the internals of File::Copy but it's possible that module ends up spawning a shell to execute "move" or perhaps even "copy" followed by "delete" in order to be OS independent. If the number of processes is an actual problem then I suggest trying to do the copying yourself, in pure Perl, by opening a read handle + a write handle and then unlink the original file after you have verified the copy is good. Maybe this would atleast help you zero in on the root cause.

-- FloydATC

Time flies when you don't know what you're doing


In reply to Re^2: number of processes created by perl script. by FloydATC
in thread number of processes created by perl script. by bsshetty17

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.