Since I'm in such a good mood, I give you a solution using Date::Manip, the coolest date module.

perl -we 'use Date::Manip; use Data::Dumper; my ($date, $end) = @ARGV; + my %out; while (Date_Cmp($date, $end) <= 0) { push @{$out{UnixDate($ +date, "%A")}}, UnixDate($date, "%b %e, %Y"); $date = DateCalc($date, +"+1 day"); } print Dumper \%out;' 'Oct 01, 2005' 'Oct 16, 2005'
Output:
$VAR1 = { 'Tuesday' => [ 'Oct 4, 2005', 'Oct 11, 2005' ], 'Saturday' => [ 'Oct 1, 2005', 'Oct 8, 2005', 'Oct 15, 2005' ], 'Sunday' => [ 'Oct 2, 2005', 'Oct 9, 2005', 'Oct 16, 2005' ], 'Wednesday' => [ 'Oct 5, 2005', 'Oct 12, 2005' ], 'Friday' => [ 'Oct 7, 2005', 'Oct 14, 2005' ], 'Thursday' => [ 'Oct 6, 2005', 'Oct 13, 2005' ], 'Monday' => [ 'Oct 3, 2005', 'Oct 10, 2005' ] };

In reply to Re: week days in a given date range by ambrus
in thread week days in a given date range by InfiniteLoop

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.