CGI Guesser Assignment

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.

To get you started, here's a version that works in plain command line perl:
#!/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

hint

I used four hidden fields. Do NOT use the hidden() function to make the fields, but write them in HTML. Using the hidden function causes a side-effect that will make the program much more difficult.

another hint

I finished the first guesser we started in class. Study the program and its source code for some pointers.
Good luck to you all!!
© Andy Harris
Indiana University / Purdue University, Indianapolis
email: aharris@.cs.iupui.edu
homepage: www.cs.iupui.edu/~aharris