SPUG: Date::Manip infinite loop

Ronald J Kimball rjk-spug at tamias.net
Sun Jan 13 12:27:56 PST 2013

On Sun, Jan 13, 2013 at 09:45:51AM -0800, Joel Grow wrote:
> Thanks for all the replies!  I hadn't considered daylight saving time, 
> but that does seem to be the culprit.
> The version of Date::Manip that "works" for me (ie, no infinite loop) 
> is 5.44.  The version that triggers the infinite loop is 6.24.  I just 
> installed the latest Date::Manip (6.38) and it still triggers the 
> infinite loop.
> What's your recommendation to solve this? I simply want to iterate 
> through N sequential days of a calendar (eg, 90 consecutive days, 
> starting March 17).

Personally, I would recommend using Date::Calc instead, which can do
calculations with actual dates, rather than dates with implicit times.

use Date::Calc qw/ Add_Delta_Days /;

my $current_date = '2012/01/01';

while ($current_date le '2012/12/31') {
  print "Current date is: $current_date\n";

  $current_date =
    sprintf "%04d/%02d/%02d",
            Add_Delta_Days(split(m{/}, $current_date), 1);


More information about the spug-list mailing list