#!/usr/local/bin/perl use strict; use warnings; print "Content-type: text/html\n\n"; use CGI qw(:standard); my $cornplanted=0; my $cornnotplanted=0; #@number1=("12" .. "25"); #$number1rand=$number1[rand @number1]; my $number1rand=int(rand(20)); my $number2=int(rand(12)); my $correctanswer=($number1rand + $number2); print "$correctanswer
"; my $output=<<_html_;
Crops planted: $cornplanted
Crops not planted: $cornnotplanted
What does this math problem equal?
$number1rand + $number2 =
_html_ print $output; chomp(my $response1 = ); if ($response1 == $correctanswer) { $cornplanted=($cornplanted + 1); print "correct!"; } elsif ($response1 != $correctanswer) { $cornnotplanted=($cornnotplanted + 1); print "not correct!"; }