- #!/usr/local/bin/perl
- print "Content-type: text/html \n\n";
-
- print "<HTML><HEAD> \n";
- print "<TITLE>CGI-TEST</TITLE></HEAD> \n";
- print "<BODY> \n";
-
- #localtime関数で値を取得して、秒、分、時、日、月、年、曜日に分ける
- ($sec,$min,$hour,$mday,$mon,$year,$wday)=localtime(time);
-
- #月の値が0〜11になるので、+1して1〜12に補正する
- $mon++;
-
- #西暦を4桁表示にする(2000年対応)
- $yy=$year + 1900;
-
- #日本語の曜日を振り当てる
- @yobi=('日','月','火','水','木','金','土');
-
- #全体を表示させる記述
-
- $nowis="ただいま、$yy年$mon月$mday日($yobi[$wday])$hour時$min分$sec秒です。\n";
- print $nowis;
-
- print "</BODY> \n";
- print "</HTML> \n";
-
- exit;
|
-
-
-
-
-
-
-
- 先頭に「#」が付く行はコメント文
-
-
-
- 1プラスする場合の演算子「++」
-
-
-
-
-
-
-
-
-
- 読み取ったwday番目の文字をyobiとして設定
- 前の行でnowisとして設定した文字列を表示
|