in reply to Getting the Latest Date Issue

“Use the CPAN, Luke!”

Using a module such as Date::Manip, you can solve problems like this very easily ... and do it in a very generic way.

  1. First, use one of the supplied routines to convert the date/time string into an internal date-value, automagically doing so in a manner that is appropriate for your chosen locale (corner of the world).
  2. Now loop for a date-offset from 0 to 44, or from 1 to 45 if you prefer...
  3. Use the library routine to calculate a date that is the appropriate number of days distant from the supplied date, and use another routine to convert that value into a string ... once again, appropriate to your particular corner of the planet.

You can, for the most part, treat the entire locale-specific conversion process as a black-box, and the returned date values as an opaque scalar type. Just the way you like it...

If it were not for CPAN, Perl would merely be “a peculiar little language.” CPAN is what makes it into a very powerful problem-solving tool. (http://search.cpan.org should be prominent in your browser bookmarks toolbar.) When you find yourself doing something like this, your gut-reaction should be to search CPAN first, where you can expect to find hundreds if not thousands of modules on almost every conceivable topic including “rocket science.”