#! /usr/local/bin/perl -w # # calendarCarp.cgi -- カレンダーの生成(今月)(エラー チェック) # # sample file name: calendarCarp.cgi use strict; use CGI; use CGI::Carp qw(fatalsToBrowser); use Calendar::Simple; use CGI::Carp qw(fatalsToBrowser); my $q = new CGI; # create new CGI object my $mon = shift || (localtime)[4] + 1; my $yr = shift || (localtime)[5] + 1900; print $q->header(-charset=>'EUC-JP'), # HTTP ヘッダーの作成 $q->start_html( -title =>"カレンダー:$yr年$mon月", -lang =>'ja-JP', -charset => 'EUC-JP'), $q->table($q->Tr([ $q->th(['日', '月', '火', '水', '木', '金', '土', ]), map {$q->td(&dateAdjust($_))} calendar($mon, $yr), ])), $q->end_html; # end the HTML sub dateAdjust { [ map { if (not defined($_)) { '  '; } elsif ($_ < 10) { ' '.$_; } else { $_; } } @{(shift)} ] }