ファイル名: ./w/if.cgi

#!/usr/local/bin/perl

#------------------------------------------------------------
$Title = 'if';
$BODY = '<BODY BGCOLOR="#000000" TEXT="#C0C0C0">';
$FONT_R = '<font color="#FF0000">';
$FONT_G = '<font color="#00FF00">';
$FONT_C = '</font>';
print "Content-type: text/html\n\n";
print "<HTML><HEAD><TITLE>$Title</TITLE></HEAD>\n";
print "$BODY\n";
print "<blockquote>\n";
#------------------------------------------------------------
$warewan = read (STDIN, $formdata, $ENV{'CONTENT_LENGTH'});

@pairs = split(/&/,$formdata);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$FORM{$name} = $value;
}
#------------------------------------------------------------
print "<form action=if.cgi method=POST>\n";
print "名前\n";
print "<BR><BR>\n";
print "<input type=text size=20 name=name>\n";
print "<BR><BR>\n";
print "<input type=submit value=OK>\n";
#------------------------------------------------------------
print "<BR><BR>\n";
print "<hr>\n";
print "名前\n";
print "<BR><BR>\n";
print "$FORM{'name'}\n";
#------------------------------------------------------------
print "<BR><BR>\n";
print "<hr>\n";
#------------------------------------------------------------
if ($FORM{'name'} eq "John") {print "Hello,John! How good of you to be here!\n";}
print "<BR>\n";
$FORM{'name'} eq "" ? print "名前を書いてください。\n" : print "こんにちは!$FORM{'name'} \n";
$FORM{'name'} eq "Paul" && print "BASSはうまくなりましたか?\n";
print "ギターはうまくなりましたか?\n" if $FORM{'name'} eq "George";
print "<BR><BR>\n";
$ENV{'CONTENT_LENGTH'}<13 || print "名前が長すぎます。\n";
print "<BR><BR>\n";
#------------------------------------------------------------
print "<hr>\n";
print "$ENV{'CONTENT_LENGTH'}";
print "<BR><BR>\n";
print "$formdata\n";
print "<BR><BR>\n";
print "$warewan\n";
#------------------------------------------------------------
print "</blockquote>\n";
print "</BODY>\n";
print "</HTML>\n";
exit;