On Monday 03 January 2005 21:48, Thomas Browner wrote:
> I have a hard time writing a script that look at file and directories
> time and date stamp then delete any thing that is so many days old. if
> someone would give me a good starting point.

You might want to take a look at File::Find and the stat() method:

#####################################################
#!/usr/bin/perl -w

use strict;
use File::Find;

my $dir = shift;

find( 
  sub {      
    my @attributes = stat($File::Find::name);
    print "found $File::Find::name - ";
    print "this file has been modified at " . $attributes[9] . "\n";
  }, 
  $dir
);
#####################################################

Inside the method specified as first parameter, you'd only need to check if 
the file modification timestamp (10th value of stat's return value) is bigger 
than the timestamp against which you want to match...if you've got any 
problems with this, post your code and surely someone will be able to help.

>
> Thanks
> Thomas

Hope this helps,

Philipp

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to