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; } }