in reply to What is the best way to get a list of all Mondays until the end of the year?

[0] Perl> $t = time(); while( $_=localtime( $t ) and m[2008] ) { m[^Mon] and print scalar localtime( $t ); $t+=86400; } Mon Aug 25 18:45:13 2008 Mon Sep 1 18:45:13 2008 Mon Sep 8 18:45:13 2008 Mon Sep 15 18:45:13 2008 Mon Sep 22 18:45:13 2008 Mon Sep 29 18:45:13 2008 Mon Oct 6 18:45:13 2008 Mon Oct 13 18:45:13 2008 Mon Oct 20 18:45:13 2008 Mon Oct 27 17:45:13 2008 Mon Nov 3 17:45:13 2008 Mon Nov 10 17:45:13 2008 Mon Nov 17 17:45:13 2008 Mon Nov 24 17:45:13 2008 Mon Dec 1 17:45:13 2008 Mon Dec 8 17:45:13 2008 Mon Dec 15 17:45:13 2008 Mon Dec 22 17:45:13 2008 Mon Dec 29 17:45:13 2008

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."
  • Comment on Re: What is the best way to get a list of all Mondays until the end of the year?
  • Download Code

Replies are listed 'Best First'.
Re^2: What is the best way to get a list of all Mondays until the end of the year?
by Rhandom (Curate) on Aug 19, 2008 at 19:28 UTC
    ++

    I had one that was equivalent in length to my other code post that did the same thing (just looked at every day) - but I thought I'd avoid doing the extra un-needed calculations by going a week at a time. But most use cases probably wouldn't care about the extra 300 (at most) iterations.
    my @a=qw(random brilliant braindead); print $a[rand(@a)];