Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Intermittent bug in module: File not getting deleted as expected

by haukex (Archbishop)
on Feb 19, 2019 at 20:49 UTC ( #1230197=note: print w/replies, xml ) Need Help??


in reply to Intermittent bug in module: File not getting deleted as expected

Although tybalt89 has already said several of these things, just to summarize: -M is the "Script start time minus file modification time, in days." The "Script start time" is kept in $^T, which is in seconds since the epoch. The file's mtime is also reported in seconds. So internally, Perl is doing a division and subtraction - it's too late in the evening here for me to go digging around in the Perl sources, but maybe there's some inaccuracy happening there.

My opinion: just don't use -M in the first place. Use stat or File::stat to get the mtime and do the comparisons to time and/or $^T yourself, then you've got everything in seconds and can do the calculations on your terms. Since you're already using -M, I assume you don't need to-the-nanosecond precision, so calculating with 1 day = 86400 seconds is probably good enough.

Replies are listed 'Best First'.
Re^2: Intermittent bug in module: File not getting deleted as expected
by stevieb (Canon) on Feb 19, 2019 at 21:04 UTC

    I was also thinking of using stat(). I even spent a fraction of time searching through my code to see where I've used it, but too many answers were flying in to bother continuing.

    Ironically, throughout this thread, I've been dealing with a timing issue in one of my Arduino projects, so I truly understand the frustration here :D

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (2)
As of 2022-08-17 01:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?