title: How can I get the first and last day of the month with Perl's DateTime?
body: <p>Is there a way to figure out the first day of the month (min day) and the last day of a month (max day), given the month as input, using <code>DateTime</code> in perl?</p>
  
  <p>So far, I figured out how to pass in a first date, last date to give me a range of days.</p>
  
  <p>But what I want to do now is just pass in a month as an argument, say <code>201203</code> and return min, maxday. </p>
  
  <p>Is that possible with DateTime?</p>
  
  <p>Also, I want to change the date format mask from YYYYMMDD to YYYY-MM-DD.</p>
  
  <pre><code>    use strict;
      use warnings;
      use DateTime;
  
      unless(@ARGV==2)
      {
          print "Usage: myperlscript first_date last_date\n";
          exit(1);
      }
  
      my ($first_date,$last_date)=@ARGV;
  
      my $date=DateTime-&gt;new(
      {
        year=&gt;substr($first_date,0,4),
        month=&gt;substr($first_date,4,2),
        day=&gt;substr($first_date,6,2)
      });
  
  
  while($date-&gt;ymd('') le $last_date)
  {
    print $date-&gt;ymd('') . "\n";
    #$date-&gt;add(days=&gt;1); #every day
    $date-&gt;add(days=&gt;30);
  }
  </code></pre>
  
  <p>Expected Results:</p>
  
  <pre><code>2012-03-01
  2012-03-31
  </code></pre>