Of course it returns 100 days; your while loop simply increments through the $date counter -- there's never any logic to treat $date like a date.

I would suggest using Date::Calc to verify that $date is really a valid date, and I'm sure there's TIMTOWTDI.

here's a sample I whomped up off the top of my head:

while ($date <=$end_date) { . . . (manipulate data here) . . . ($this_year, $this_month, $this_day) = ($date =~/(\d{4})(\d(2})(\d{2}) +/) if (!checkdate ($this_year, $this_month, $this_day) { # a new month dawns $this_day=1; if ($this_month ==12) {#did december just pass $this_year++; $this_month=0; } $this_month++; #add one to the month. $date = $this_year . $this_month . $this_day; } }
Note that there's a lot of improvement to be wrung from this -- the regexp to split the date and the concatenation to reform it could be removed by using just $this_year and  $this_month and $this_day, but this might require some other adjustments to your code. update : There's a function in Date::Calc called Add_Delta_YMD which does pretty much the same thing.

In reply to Re: Date Range Parsing by boo_radley
in thread Date Range Parsing by Tuna

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.