Thanks to this piece on wired I learnt about conway's doomsday algorithm to get the day of the week of any date.
Trying to wrap my head around the algorithm I decided to implement it as a learning exercise.
Here is the code, enjoy :D

Update, now with use strict!

#!/usr/bin/perl use 5.14.2; use warnings; use strict; use autodie; if(!defined($ARGV[0])){ die "gimme a date DD/MM/YYYY!\n"; } my $date = $ARGV[0]; my($day,$month,$year); if(!($date =~ m#(?<day>\d\d)/(?<month>\d\d)/(?<year>\d\d\d\d)#)){ print "$date did not match format DD/MM/YYYY\n"; die; } else{ $day = $+{day}; $month = $+{month}; $year = $+{year}; } my $isleap; if( $year =~ m/\d\d00/){ my $century = $year / 100; $isleap = $century % 4 == 0; } elsif($year =~ m/\d\d(?<decade>\d\d)/){ $isleap = $+{decade} % 4 == 0; } if(!$isleap && $month == 02 && $day == 29){ die "this ain't a leap year so $date is wrong!\n"; } my $century_anchor_day = ((5 * (($year/100)%4))%7); my $decade; if($year =~ m/\d\d(?<decade>\d\d)/){ $decade = $+{decade}; } if($decade % 2 == 0){ $decade /= 2; } else{ $decade += 11; $decade /=2; } if($decade %2 == 0){ $decade %= 7; } else{ $decade += 11; $decade %= 7; } my $anchorday_drift = 7- $decade; my @anchorday_week; my $year_anchor_day = ($century_anchor_day+$anchorday_drift)%7; given ($year_anchor_day){ when(0){@anchorday_week = qw(tuesday wednesday thursday friday sat +urday sunday monday );} when(1){@anchorday_week = qw(wednesday thursday friday saturday su +nday monday tuesday);} when(2){@anchorday_week=qw(thursday friday saturday sunday monday +tuesday wednesday);} when(3){@anchorday_week=qw(friday saturday sunday monday tuesday w +ednesday thursday);} when(4){@anchorday_week=qw(saturday sunday monday tuesday wednesda +y thursday friday);} when(5){@anchorday_week=qw(sunday sunday monday tuesday wednesday +friday saturday);} when(6){@anchorday_week = qw(monday tuesday wednesday thursday fri +day saturday sunday);} } my $doomsdates = { '01'=>3, '02'=>28, '03'=>0, '04'=>4, '05'=>9, '06'=>6, '07'=>11, '08'=>8, '09'=>5, '10'=>10, '11'=>7, '12'=>12, }; if($isleap){ $doomsdates->{'01'} = 4; $doomsdates->{'02'} = 29; } my $diff_to_doomsdates = $day - $doomsdates->{"$month"}; if($diff_to_doomsdates < 0){ $diff_to_doomsdates *= -1; } my $nbdays = $diff_to_doomsdates % 7; print "$ARGV[0] was a $anchorday_week[$nbdays]\n";</readmore>

In reply to Doomsday algorithm by QuillMeantTen

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.