kleinbiker7 has asked for the wisdom of the Perl Monks concerning the following question:
The prob is that -M doesnt seem to be working on these files. Is it the filename, or is it a permissions prob?
Here is the code that I am using:
Age is blank and after the sprintf statement it is 0, which is NOT correct!while ($file = readdir (DIR)) { if ($file !~ /^\.+$/) { # GET THE AGE OF THE FILE IN DAYS # -M gives us the age of the file in days when script started. # It needs to be rounded! $age = -M ($file); $age = sprintf ("%0.0f", $age); print "FILE: $file:\n\tAGE: $age\n"; if ($age > 2) { print "DELETE ME!\n"; } else { print "SAVE ME\n"; } } }
Here is a sample listing of the files that I am trying to determine the age of (in days).
Thanks Robert7 -rw-rw-r-- 1 root 6441 Jun 17 00:00 2001-06-16T194921Z_0 +1_N16487427_RTRIDST_0_HEALTH-DOCTORS-UNION.XML 6 -rw-rw-r-- 1 root 5148 Jun 17 04:55 2001-06-17T082435Z_ +01_L17466768_RTRIDST_0_HEALTH-ISRAEL-TEVA.XML 9 -rw-rw-r-- 1 root 8558 Jun 17 13:05 2001-06-17T163225Z_ +01_N17218051_RTRIDST_0_-FINANCE-IPO-OUTLOOK.XML 10 -rw-rw-r-- 1 root 9490 Jun 17 13:50 2001-06-17T171804Z_ +01_N17360454_RTRIDST_0_CONGRESS-HEALTH.XML 7 -rw-rw-r-- 1 root 6176 Jun 18 03:05 2001-06-18T063312Z_ +01_ZUR821703_RTRIDST_0_HEALTH-MEDICA-IMPLANTS-U RGENT.XML
Edit: chipmunk 2001-06-20
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How can I get -M to work properly?
by clintp (Curate) on Jun 20, 2001 at 19:35 UTC | |
by kleinbiker7 (Sexton) on Jun 20, 2001 at 19:44 UTC | |
|
Re: How can I get -M to work properly?
by azatoth (Curate) on Jun 20, 2001 at 19:33 UTC | |
|
Re: How can I get -M to work properly?
by converter (Priest) on Jun 20, 2001 at 20:09 UTC | |
|
Re: How can I get -M to work properly?
by buckaduck (Chaplain) on Jun 20, 2001 at 19:36 UTC | |
|
Re: How can I get -M to work properly?
by bikeNomad (Priest) on Jun 20, 2001 at 19:36 UTC |