brain hurt and file test

Randal L. Schwartz merlyn at stonehenge.com
Thu Jun 13 10:53:46 CDT 2002


>>>>> "mikeraz" == mikeraz  <mikeraz at patch.com> writes:

mikeraz> We tracked it down.  The -[AMC] file test . . . well as `man perlfunc`
mikeraz> will tell you does not return the [acm]time of the file.  They:

mikeraz>     -M  Age of file in days when script started.
mikeraz>     -A  Same for access time.
mikeraz>     -C  Same for inode change time.

mikeraz> Ah, when the script started.  Ah, express in days. (??)

mikeraz> Note, if the file changed since the time the script started this number will
mikeraz> be negative.  

mikeraz> Note, it is expressed in days.  Multiply by 86400 if you want the value 
mikeraz> expressed in seconds.  

mikeraz> So if you want to know how long a file has not been mucked with (as I do), 
mikeraz> use the stat function.  

Or add

  $^T = time;

to the top of your checking loop, which changes the offset used by -A
to *now*.

Actually, then:

        $^T = time - 30;
        if (-A $file > 0) {
                # file was last modified more than 30 secs ago
        }

would be a cheap way to do this without scaling for days/seconds. :)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn at stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
TIMTOWTDI



More information about the Pdx-pm-list mailing list