What I tend to do is use the Time::Local module, specifically them
timelocal funciton.  It's like the reverse of the localtime function. You
give timelocal a series of parameters defining a date and it returns you
the seconds since epoch.  Then you can add (24*60*60)x2 for 2 days worth of
seconds...

You may want to watch your time manipulation, if you are looking for two
full days (48 hours) this will work.  If you are looking for fuzzy 2 days
(ie: if it was created monday then anytime on wednesday it can be deleted,
you may want to change the time on the file to reflect midnight on the day
the file was last modified, and then do you time manipulation from there

Ok that doesn't sound to clear....I can give it another shot if you want :)

#grab the modification time from the file
my $modtime = (stat($filename))[9];   # Already in seconds since epoch

#add two days worth of seconds
my $tmptime = $modtime + 2*(24*60*60);

#get localtime in seconds since epoch
my $currtime = time;

#and compare
unlink $filename if ($currtime > $tmptime)

something like that should work, its pretty ugly and can be made better,
but that gives you a plan




                                                                                       
                                                
                      Francesco                                                        
                                                
                      Guglielmo                To:       Craig 
Moynes/Markham/IBM@IBMCA                                                
                      <f.guglielmo@caen        cc:                                     
                                                
                      .it>                     Subject:  Re: Date                      
                                                
                                                                                       
                                                
                      07/12/2002 10:53                                                 
                                                
                      AM                                                               
                                                
                                                                                       
                                                
                                                                                       
                                                



Craig Moynes/Markham/IBM wrote:

>You could write a script that reads a file that contains a list of files.
>Compare the modification file of each file to the current date, if the
file
>is at least two days old try and delete it.
>
>Then schedule this script to run everyday, take a look at:
> man crontab
>
That's clear!!!
But if the date in my file is 30 July?How can I say that 30 July + 2
days = 1 Aug?

>






-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to