Hello everyone,
I've been writing a Quiz game with CGI.pm to run on my website and am having some problems checking the answers. The questions ask change randomly every time so I'm trying to pass the question and the answer to the page so when it reloads it has something to compare it to. I've written some code (included below) that gives some odd output and I couldn't find the bug in it.
my $match;
if ($last_question eq $answer) {
$match = 'yes';
}
print header,
start_html( -title => 'Esperanto Quiz' ),
h1('Esperanto Quiz'),
p( b($question) ),
p( $match ),
p( $last_question,
$answer,
),
start_form,
textfield( -name => 'answer',
-size => 40,
-maxlength => 40 ),
br,
submit,
hidden ( -name => 'last_question',
-value => $lq,
),
end_form,
end_html;
The problem is that when I try to print out the
$last_question and the
$answer variable the
$last_question seems to stay the same. They also don't match in the
if ( $last_question eq $answer ) statment. Hope someone else can find the bug in this because I've been having a lot of trouble with it. Thanks.
-Ben Jacobs (dooberwah)
one thing i can tell you is you got to be free
http://dooberwah.perlmonk.org
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.