If your on unix you can just use find with -mtime and an exec rm. If all
you want to do is perge files. 

-----Original Message-----
From: Raymond Wan [mailto:[EMAIL PROTECTED] 
Sent: 20 November 2008 15:39
To: beginners@perl.org
Subject: [Fwd: Re: Determining if a file is more than so many days old]


Sorry, forgot to send it to the list...

Ray

-----
Hi Andrew,

AndrewMcHorney wrote:
 > I am working on a perl script that will go through a directory and
 > it's subdirectories and purge all the files that are more than a
 > specified number of days old. I am using a Unix system so I do a find
 > command to gather up the files I want. I then am going to do a stat
 > command to find the date the file was created (it is never modified)
 > and then determine if it is to be deleted. What is the easiest way to
 > determine if a date is more than x number of days old.

In Perl? I wrote such a script -- yet, I do not know if this is the
"easiest" way to do it.

I used -M to do it (http://perldoc.perl.org/functions/-X.html):

my $days = sprintf ("%.2f", -M $fn);
if ((defined $days) && ($days > $daylimit)) {
rmtree ($dir);
}
}

where $daylimit is a value provided earlier. Seems to work fine...

Ray


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



This e-mail is from the PA Group.  For more information, see www.thepagroup.com.
This e-mail may contain confidential information.  
Only the addressee is permitted to read, copy, distribute or otherwise use this 
email or any attachments.  
If you have received it in error, please contact the sender immediately.  
Any opinion expressed in this e-mail is personal to the sender and may not 
reflect the opinion of the PA Group.
Any e-mail reply to this address may be subject to interception or monitoring 
for operational reasons or for lawful business practices.


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


Reply via email to