Your assignment is to make a cgi-based version of a number guessing game.
The human player will choose a number, and the computer will try to
guess it. You are to write this program in perl as a CGI program.
#!/usr/local/bin/perl
print "Think of a number, and I will guess it! \n";
$guess = 50;
$range = 25;
$response = "";
$tries = 0;
while ($response ne "C"){
print "My guess is $guess.\n";
print "is that (H)igh, (L)ow, or (C)orrect? \n";
$response = <STDIN>;
chop $response;
$response = uc($response);
if ($response eq "H"){
$guess = $guess - $range;
} elsif ($response eq "L"){
$guess = $guess + $range;
} elsif ($response eq "C"){
print "I got it!!! \n";
print "it took me $tries turns. \n";
} else {
print "that was not a valid answer. \n";
} # end if
$range = int($range /2);
if ($range < 1){
$range = 1;
} # end if
$tries++;
} # end while loop