Math Drill Program Problem

I have written a program which will have 10 "10-times table" question, generated by the random number which is range from 1-10. And when the "Submit" button had pressed, the screen will shows up the number of Right and Wrong answer. But I keep having problem on the result screen. The following is my code, can you guys experts help me. Thank you very much !!

P.s. Is there any way to use the "for" loop to display the question part. So I don't need to type it 10 times as it shown below. Thanks again !
========================================
#!c:\Perl\bin\perl
use CGI qw(:all);
use CGI::Carp qw(fatalsToBrowser);

for ($i = 1; $i <= 10; $i++){
  $num1 = int(1 + rand 10);
  $num2 = int(1 + rand 10);

  push @m, $num1;
  push @n, $num2;
  push @r, $num1 * $num2;
}

if (!param('query0')){
print header, start_html('MATH DRILL PROGRAM'),
h1('Math Drill Program'),
start_form,

"$m[0] * $n[0] = ",  
textfield('query0'),
hidden('answer0', $r[0]),
p,

"$m[1] * $n[1] = ",
textfield('query1'),
hidden('answer1', $r[1]),
p,

"$m[2] * $n[2] = ",
textfield('query2'),
hidden('answer2', $r[2]),
p,

"$m[3] * $n[3] = ",
textfield('query3'),
hidden('answer3', $r[3]),
p,

"$m[4] * $n[4] = ",
textfield('query4'),
hidden('answer4', $r[4]),
p,

"$m[5] * $n[5] = ",
textfield('query5'),
hidden('answer5', $r[5]),
p,

"$m[6] * $n[6] = ",
textfield('query6'),
hidden('answer6', $r[6]),
p,

"$m[7] * $n[7] = ",
textfield('query7'),
hidden('answer7', $r[7]),
p,

"$m[8] * $n[8] = ",
textfield('query8'),
hidden('answer8', $r[8]),
p,

"$m[9] * $n[9] = ",
textfield('query9'),
hidden('answer9', $r[9]),
p,

submit('Submit Answer'), reset('Start Over'), end_form, end_html;
}
else{
  $right = 0;
  $wrong = 0;

  for ($j=0; $j<=10; $j++){
    $query[$j] = param('query[$j]');
    $answer[$j] = param('answer[$j]');
  }
 
  for ($k=0; $k<=10; $k++){
    if ($query[$k] == $r[$k]){
      $right = $right + 1;
    }
    else{
      $wrong = $wrong + 1;
    }
  }
 
print header,
      start_html('Math Drill Result'),
      h1, "<PRE>";
print << "END";
Math Drill Program Result:
<HR>
Right Answer = $right
Wrong Answer = $wrong
<HR>
END
print "</PRE>", end_html;
}
   
 
LVL 2
clo1Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

clockwatcherCommented:
Here you go:

#!c:\Perl\bin\perl
use CGI qw(:all);
use CGI::Carp qw(fatalsToBrowser);

if (!param('query1')){
print header, start_html('MATH DRILL PROGRAM'),
h1('Math Drill Program'),
start_form;

for ($i=1; $i <= 10; $i++) {

  $num1 = int(1 + rand 10);
  $num2 = int(1 + rand 10);

  print "$num1 * $num2 = ", textfield("query$i"), hidden("answer$i", $num1 * $num2), p, "\n";
 
}

 print submit('Submit Answer'), reset('Start Over'), end_form, end_html;
}
else{
 
  $right = 0;
  for ($j=1 ; $j <= 10; $j++){
    $right++ if param("query$j") == param("answer$j");
  }
 
  $wrong = 10 - $right;
   
print header,
      start_html('Math Drill Result'),
      h1, "<PRE>";
print << "END";
Math Drill Program Result:
<HR>
Right Answer = $right
Wrong Answer = $wrong
<HR>
END
print "</PRE>", end_html;
}
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
clo1Author Commented:
It is excellent. I am so appreciate for your affort, Thanks.

But one thing is when I run the program, it shows up this error message.

Can't find string terminator "END" anywhere before EOF at c:/program files/apache group/apache/cgi-bin/Testing.pl line 33.

But I have checked it has no problem. Please help again. THANKS !
0
ozoCommented:
Is "END" the only thing on the line?  or it it really "END  " or "  END"?
0
clo1Author Commented:
Yes, it is only "END" as you show me. Did you tried to run it? Do you have any problem?
0
clo1Author Commented:
I just found out it is the problem of some of the hidden characters which generated when I copy from the browser to my editor. Thanks for you help. I am appreciate about that.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.