Currently I am trying to find the age of certain files in days. So I am trying to use -M to do that.

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:

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"; } } }
Age is blank and after the sprintf statement it is 0, which is NOT correct!

Here is a sample listing of the files that I am trying to determine the age of (in days).

7 -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
Thanks Robert

Edit: chipmunk 2001-06-20


In reply to How can I get -M to work properly? by kleinbiker7

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.