Beefy Boxes and Bandwidth Generously Provided by pair Networks httptech
No such thing as a small change
 
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 rifling through the Monastery: (13)
As of 2014-04-18 18:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (471 votes), past polls