#!/usr/local/bin/perl
#
# Perlサーバを使った辞書引きCGI
#
require 'clientserver.pl';
$len = $ENV{'CONTENT_LENGTH'};
print <<EOF;
HTTP/1.0 200 OK
Content-type: text/html
<html>
<head>
<title>
英和辞書検索結果
</title>
</head>
<body bgcolor=#FFFFDD text=#000000 link=#0000EE vlink=#551A8B>
<dl>
EOF
for $i (1..$len){
$_ .= getc(STDIN);
}
while(/^(.*)%([0-9a-f][0-9a-f])(.*)/i){
print "$_\n";
$_ = sprintf("%s%c%s",$1,hex($2),$3);
}
$s = $_;
/^word=(.*)$/;
$word = $1;
&clientopen(5678,'CLIENTSOCK')
print CLIENTSOCK "$word\n";
$_ = <CLIENTSOCK>;
s/\s*$//;
@list = split(/\r/,$_);
for $list (@list){
($e,$j) = split(/\t/,$list);
print "<dt> <font size=+1 color=blue>$e</font>\n";
print "<dd> $j\n";
}
print <<EOF;
</dl>
</body>
</html>
EOF