Re: Modifiaction time of file



On Fri, 2006-28-04 at 08:51 -0700, anu p wrote:
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)) {

while( defined( $file = readdir DIR )){
next unless -f "$fail_dir/$file";

# readir() returns all directory entries including:
# files, directories, symbolic links, pipes,
# special character devices, special block devices
# You should limit your code to just regular files
# or regular files and symbolic links.
# See `perldoc perlfunc` and search for 'Alphabetical Listing of Perl
Functions'
# See `perldoc -f readdir`

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: What will you be hunting with this Fall?
    ... > a rear sight and a slightly prouder front sight than ... > add a forward sling loop and a sling button toward the ... > Do You Yahoo!? ... Mail has the best spam protection around ...
    (rec.hunting)
  • Re: Ousted
    ... South Korean PM played golf....result? ... asked him to resign. ... Do You Yahoo!? ... Mail has the best spam protection around ...
    (soc.culture.singapore)
  • Re: Duplicate disk in a volume group
    ... think this one would not be good because there is still an entry for a GOOD ... Duplicate disk in a volume group ... Do You Yahoo!? ... Mail has the best spam protection around ...
    (AIX-L)
  • RE: FreeBSD on Dell PE850
    ... When I install using the 6.1 disk one I get the error "Add of package ... Do You Yahoo!? ... Mail has the best spam protection around ... MailScanner thanks transtec Computers for their support. ...
    (freebsd-questions)
  • Re: [kde-linux] Cant login via kde - hangs when "initializing peripherals"
    ... failsafe term then startkde - no problems ... I can login in under gnome - no problem. ... Do You Yahoo!? ... Mail has the best spam protection around ...
    (KDE)