in reply to having trouble with simple math game
It seems to be reading the input as blank before the user even enters the answe
Your code is not giving the user a chance to enter the number that will be saved in $response1, then, your comparisons operators are those used for strings and not for numbers, and above all, you missed important warnings by not useing strict and warnings, here is your code retouched....
An interesting question, what if you wanted your program to respond to a non-conforming user entry (i.e when a user enters a sentence rather than a number)?
Scalar::Util has an answer for you :)
print "Content-type: text/html\n\n";
use CGI qw(:standard);
#@number1=("12" .. "25");
my $correctanswer=($number1rand + $number2);
print "$correctanswer <br>";
<form method="post" action="foodaddition.cgi" name="form2">
Crops planted: $cornplanted <br>
<input type="hidden" name="$cornplanted" id="$cornplanted" />
Crops not planted: $cornnotplanted <br>
<input type="hidden" name="$cornnotplanted" id="$cornnotplanted" />
What does this math problem equal? <br>
$number1rand + $number2 = <input type="text" name="response1" id="resp
<input type="hidden" name="response1" id="response1" />
<input type="submit" name="submit" value="Submit" />
chomp(my $response1 = <STDIN>);
if ($response1 == $correctanswer)
$cornplanted=($cornplanted + 1);
elsif ($response1 != $correctanswer)
$cornnotplanted=($cornnotplanted + 1);
print "not correct!";
Excellence is an Endeavor of Persistence.
A Year-Old Monk :D .