![]() |
|
Think about Loose Coupling | |
PerlMonks |
Re: Compare Dateby rob_au (Abbot) |
on Mar 05, 2002 at 12:37 UTC ( #149345=note: print w/replies, xml ) | Need Help?? |
There is a major flaw with this application logic - What if the signup was performed on the 31st of a month? Using this approach to this problem, the emails would be sent out to the user seven times over the year, that is, only those months with 31 days. In short - it doesn't work. When faced with this application requirement previously, I approached this problem somewhat differently. The approach taken was to have the script check the number of days since the sign up was performed and send out the email if thirty days have passed - Or more specifically, the number of days within the year, divided by the number of emails which you wish to send to the user over the year. To implement this application logic, the Date::Calc module proved to offer all of the date-related functions required - A snippet of the code employed follows:
For this project, I did also look at other date-related modules on CPAN but found the scope and module documentation of Date::Calc by far the most complete and inviting to work with.
perl -e 's&&rob@cowsnet.com.au&&&split/[@.]/&&s&.com.&_&&&print'
In Section
Seekers of Perl Wisdom
|
|