gyasuda has asked for the wisdom of the Perl Monks concerning the following question:
I have a file /tmp/log/startOnline.was_20050801_0701.joblog which has a timestamp of Aug 01 2005. The last time it was accessed and modified was like over 370 days. Of course, the /tmp/log directory has many log files.
In Perl, here is part of the code:
$path = "/tmp/log"; $file = "startOnline.was_*_*.joblog"; @TODELETE = `ls -t $path/$file`; foreach $logfile (@TODELETE) { printf ("%12s %5d %5d %5d\n", $logfile, -M $logfile, -A $logfile, -C + $logfile); }
The output lists "/tmp/log/startOnline.was_DATE_TIME.joblog 0 0 0".
In Perl, I thought the "-M" file-test operator returns how long since the file has been modified, "-A" returns how long since the file has been accessed, and "-C" returns how long since the file's inode has been accessed.
If $logfile has the full path of the filename, how come the file-test operators display zeroes?
If I can get the file operators to work, I can finish my Perl script to start deleting the older log files.
Any help would be appreciated.
Gary
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Perl File-Test Operators
by ikegami (Patriarch) on Aug 11, 2006 at 02:12 UTC | |
Re: Perl File-Test Operators
by graff (Chancellor) on Aug 11, 2006 at 03:08 UTC | |
Re: Perl File-Test Operators
by jwkrahn (Abbot) on Aug 11, 2006 at 02:33 UTC | |
Re: Perl File-Test Operators
by GrandFather (Saint) on Aug 11, 2006 at 02:17 UTC | |
Re: Perl File-Test Operators
by ptum (Priest) on Aug 11, 2006 at 02:18 UTC |