Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Random script crashes related to File::Copy

by tokpela (Chaplain)
on Apr 30, 2009 at 08:41 UTC ( #761061=note: print w/ replies, xml ) Need Help??


in reply to Random script crashes related to File::Copy

As others have mentioned above, this may be because the file has not yet finished writing. I would use a "stable" file concept and check that the file has not been modified since X time period.

# check if the file has stablized for over 30 seconds if (is_stable_file($file, 30)) { process($file); } sub is_stable_file { my $file = shift; my $wait_seconds = shift || 0; my $result = 1; if ($wait_seconds > 0) { my ($mtime) = (stat($file))[9]; my $secs_since_mod = (time - $mtime); if ($secs_since_mod < $wait_seconds) { $result = 0; } } return $result; }


Comment on Re: Random script crashes related to File::Copy
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://761061]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2015-07-30 01:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (269 votes), past polls