Modifiaction time of file



Hi,

I have a requirement where I need to look at the age
of file, if it's older than 2 days, I should remove
it.
I am trying to use the '-M ' filehandle in my script,
it does not work.

I get the following error
Use of uninitialized value in numeric gt (>) at
../temp_age.pl line 12.


#!/usr/bin/perl

use strict;
use warnings;

my $fail_dir =
"/home/anupamaperi/failed_tests/regress_26";
my ($file, $age);

opendir (DIR, $fail_dir) || die "cannot open, no
$fail_dir dir $!";
while ($file = readdir (DIR)) {
if (-M $file > 2) {
print("$file\n");
unlink($file);
}
}

Any ideas where am I going wrong?

Thanks,
Anu.

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
.



Relevant Pages

  • Re: Password
    ... the age of your child, ... You have a son named Justin and the dog's name is ... Do You Yahoo!? ... Mail has the best spam protection around ...
    (Fedora)
  • Re: Is it good to be a Singaporean?
    ... How well are you prepared for your old age when suddenly you become a Lau Ah Pek? ... Do You Yahoo!? ... Mail has the best spam protection around ...
    (soc.culture.singapore)
  • Re: problem runing code | strange Error
    ... use strict; ... use warnings; ... Do You Yahoo!? ... Mail has the best spam protection around ...
    (perl.beginners)
  • Re: unit messages
    ... use strict; ... use warnings; ... Do You Yahoo!? ... Mail has the best spam protection around ...
    (perl.beginners)
  • Re: THE most boh liau budget of all
    ... pleasure a man can have at this age is by robotic or mechanized masturbation. ... Do You Yahoo!? ... Mail has the best spam protection around ...
    (soc.culture.singapore)