Terse calendar with CGI

use strict;
use warnings;
use CGI qw(:standard);

use Date::Calc qw( Days_in_Month Day_of_Week Month_to_Text Today
                   Day_of_Week_Abbreviation );

print header(),
  start_html(
            -title => "My Little Calendar",
            -head => style({ -type => 'text/css' },
                           join('', <DATA>)),
  );

my ($year, $month, $day) = Today();
my @month = (1 .. Days_in_Month($year, $month));
my $offset = Day_of_Week($year, $month, 1) - 1;
unshift @month, map { undef } 1 .. $offset;
my $end_of_month_offset = 7 - (@month % 7);
push @month, (undef) x $end_of_month_offset;
my @Cmonth = ();
while (@month) { push @Cmonth, [ splice @month, 0, 7 ] }

print
    table(
          Tr(
             td(
                { -class   => 'month',
                  -colspan => 7
                },
                uc(Month_to_Text($month))
               ),
            ),
          Tr(
             map {
                 td({ -class => 'day' },
                    Day_of_Week_Abbreviation($_))
             } (1 .. 7)
            ),
          map {
              Tr(
                 map {
                     td({ -class => $_ && $_ == $day ?
                              'today' : 'date' }, $_)
                     } @$_
                 )
              } @Cmonth
          );

__DATA__
table, tr {
 border:0;
 padding:0;
 margin:0;
}
tr {
 text-align:center;
}
td {
 font-family:optima,helvetica,sans-serif;
 font-size:60%;
 margin:2px;
 padding:1px;
}
.day {
 background-color:#9ca;
 width: 2.2em;
 font-weight:bold;
}
.date {
 background-color:#9cf;
 height: 2em;
}
.today {
 background-color:#cef;
 height: 2em;
}
.month {
 text-align:center;
 background-color:#68b; 
 font-size:11pt;
 letter-spacing:.2ex;
 font-weight:bold;
}
APRIL
Mon Tue Wed Thu Fri Sat Sun
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30
digg stumbleupon del.icio.us reddit Fark Technorati Faves
Your information (required) Name*
Email*
Website

* Indicates required fields; email is used for validation and is not displayed on the site.

Your comment
Commenting on Terse calendar with CGI
Title

Body is limited to ≈1,000 words. Paragraphs—but not line breaks—are automatically inserted. Valid XHTML is required. These are the allowed tags–

<a href=""></a> <br/> <acronym title=""></acronym> <abbr title=""></abbr> <code></code> <pre></pre> <tt></tt> <ins></ins> <del></del> <hr/> <cite></cite> <b></b> <i></i> <sup></sup> <sub></sub> <strong></strong> <em></em> <h1></h1> <h2></h2> <h3></h3> <q></q> <blockquote></blockquote>