On Sun, Mar 05, 2000 at 01:08:24PM -0500, gnielson wrote:
| I am trying to figure out a way to test a file with perl to find out when
| it was lat modified and if that was within the last minute, do something,
| otherwise exit.
|
| I've gotten as far as this:
|
| $file='filename.txt';
| $lastModified = printf "%f", -M $file;
|
| which gives me a number such as 0.122986 if the file was modified around a
| day ago and 0.000023 if it was modified just a few seconds ago. Is this
| modified number in seconds? How is it calculated? I tried an if/else
| statement where if $lastModified was less than 0.000060 an action would
| happen but I could not get it to work.
Well, you could Read The Fu^hine Manual.
"man perlfunc":
[...]
-M Age of file in days when script started.
[...]
So: (date script started - date on file), converted to days.
Why not just stat() the fine and compute on the mtime, which is in
seconds since the epoch? It's also in the FM, under "stat".
--
Cameron Simpson, DoD#743 [EMAIL PROTECTED] http://www.zip.com.au/~cs/
Success in software development depends on making a carefully planned
series of small mistakes in order to avoid making unplanned large
mistakes. - Steve McConnell, _Software Project Survival Guide_
--
To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
as the Subject.