Update Based on -M

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I have user files i need to update if they haven't been updated since
01/03/09. the code i have below thinks they aren't old enough. what am
i doing wrong? thanks in advance for your help.

$oldage=(-M "members/$user/files/product.txt");
if ($oldage < "01/03/09") {
print qq~yep-it's older~;
print qq~nope~;

Re: Update Based on -M

There's some problems with you attempt

1.) $oldage does not return the date as a string (see previous response
from Anfrzej

2.) Even if $oldage would return a string, then you had to make a string
comparison with lt and not a numerical comparison with '<'

3.) Performaing a string comparison on dates with the format 'mm/dd/yy'
would not compare correctly as for example
'01/04/08' lt '01/03/09' would return false, though it should be true.

tghe best format for date strings if you want to sort / compare is
something like 'yyyy-mm-dd'

You can use the module Time::Local to convert  a given date into
'seconds since the system epoch'



zoomcart.com wrote:
Quoted text here. Click to load it

Site Timeline