Make a list of which (first ...) and WHICH (First ...) so that you generate the CGI parameter names on the fly. Store questions and answers in arrays. I have rewritten part of your code to show you how this is done.
#!/usr/bin/perl -w use strict; use CGI qw(:standard); my @which = qw/ first second third fourth fifth /; my @WHICH = qw/ First Second Third Fourth Fifth /; print header, start_html("Quiz Maker"), h1("Quiz Maker"); if (param()) { my $who = param("firstname"); my $who2 = param("lastname"); my $email = param("email"); my @questions = map { param("$WHICH[$_]Question") } 0..4; my @answers = map { param("Answer$WHICH[$_]Question") } 0..4; #my @user_answers = ... # you get the picture #my @choices = ... print p("Thank You. Here is your quiz:"); print p("Name: $who $who2"); for (0..4) { print hr(), start_form(); print p("Question #". $_+1 .": $questions[$_]"); print p("Answer:", textfield("UserAnswer$WHICH[$_]Question")); } } else { print hr(), start_form(); print p("What's your first name?", textfield("firstname")); print p("What's your last name?", textfield("lastname")); print p("Enter your e- mail address", textfield("email")); for (0..4) { print hr(), start_form(); print p("What is your $which[$_] question", textfield("$WHICH[ +$_]Question")); print p("Please enter the answer", textfield("Answer$WHICH[$_] +Question")); } print hr(), start_form(); print p(submit("Submit"), reset("Reset")); print end_form(), hr(); } print end_html;

In reply to Re: Simple Quiz Maker by Roger
in thread Simple Quiz Maker by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.