in reply to How Many Mondays in Date Range?

Maybe I'm mistaken... but if I read your problem right this should do it...
$daycounts[($firstday+$_-1)%7] = int(($days+6-$_)/7) for(0..6);
BTW: this takes monday as 1, sunday as 7 but outputs a seven elemet array going from monday to sunday... I'm not sure if that is what you wanted, but it seemed like it was

                - Ant

Replies are listed 'Best First'.
Suaveant's Solution RE: How Many Mondays in Date Range?
by THuG (Beadle) on Aug 02, 2001 at 18:27 UTC

    This works very well. It doesn't require a lop larger than 7. But I take out the -1 to get

    $daycounts[($firstday+$_)%7] = int(($days+6-$_)/7) for(0..6);

    And get an array where Monday is 0 and Sunday is 6. This way I can use the UnixDate result -1 to match it to this result.

    -Travis

      I put the -1 in because you said $firstday went from 1-7, was I wrong?

                      - Ant

        Oh, not at all. But everyone brought up a good point that I was wasting the 0 position of the array. Besides, it is just as easy to subtract 1 from the UnixDate result when I ask how many Tuesdays there were.

        You weren't wrong, I was just stuck on using 1..7. I should've shifted to 0..6.

        -Travis