A good module for finding the difference between two dates in days is Date::Calc. I used it to do something similar to what I think you are attempting to achieve. I wrote a script that checks a list of important days (i.e. - birthdays, anniversaries, etc) and emails me a reminder two weeks in advance. What can I say, I'm a forgetful person at times.
Anyway, the Date::Calc module can be used to find the number of days, as well as a huge assortment of other cool bits of information. I use the line $difference = Delta_Days ($current_year, $current_month, $current_day, $stored_year, $stored_month, $stored_day); and the Date::Calc module returns the days between. The module takes standard input: yyyy for the year, mm (0-11) for the month, and dd (1-X) for the day. I also use the standard localtime[3,4,5] to get today's date before sending it to the Date::Calc module.
Read up on the module and you'll discover its many uses. -Eric | [reply] [d/l] [select] |
I doubt that anything beyond the core Perl functions will be
needed:
my $birthday = "2/29/1980"; # (not really -- just an example)
my ($month,$date) = split /\//, $birthday;
my ($today,$thismonth) = (localtime)[3,4];
$thismonth++; # localtime gives you "0" for January
&letsParty if ( $today == $date and $thismonth == $month );
Do read the output of "perldoc -f localtime" -- a great read.
| [reply] [d/l] |
You may find Schedule::Cron will be helpful depending on the exact nature of the trigger you are looking for.
Hope this helps :-)
| [reply] |