use strict; use CGI qw(:standard); use Date::Calc qw(:all); print header(), start_html( -title => "My Little Calendar", -head => style({ -type => 'text/css' }, join('', ),), ); 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; }