#!/usr/bin/perl use strict; use warnings; use CGI qw/:standard/; my @words = ( 'amiko::friend', 'kafo::coffee', 'filo::son', 'kuko::cake', 'frato::brother', 'lakto::milk', 'instruisto::teacher', 'pano::bread', 'knabo::boy', 'sukero::sugar', 'patro::father', 'teo::tea', 'akvo::water', 'butiko::shop', 'limonado::lemonade', 'papero::paper', 'plumo::pen', 'taso::cup', ); srand ( time() ^ ($$ + ($$ << 15)) ); my $answer = param('answer'); ($answer) = ( $answer =~ /^(\w*)$/ ); my $language = param('language'); $language = 'Esperanto' unless $language; my $last_question = param('last_question'); ($last_question) = ($last_question =~ /^(\w*)$/); my ($esperanto, $english) = split /::/, @words[rand(scalar(@words))]; my $question = sprintf("%s\n", $language eq 'Esperanto' ? $esperanto : + $english); my $match = gradeit( $last_question, $answer ); sub gradeit { my $first = shift; my $second = shift; my $together; if ($language eq 'Esperanto') { $together = join "::", $first, $second; } else { $together = join "::", $second, $first; } my $match = "No. $first != $second"; foreach my $word (@words) { if ($word eq $together) { $match = "Correct. $first = $second"; last; } } return $match; } param('last_question', $question); print header, start_html( -title => 'Esperanto Quiz' ), h1('Esperanto Quiz'), p( b( 'Question: '), 'What does ', b($question), ' mean?' ), p( $match ), start_form, textfield( -name => 'answer', -size => 40, -maxlength => 40 ), br, radio_group( -name => 'language', -values => ['English', 'Esperanto'], -default => 'Esperanto', -linebreak => 'true'), hidden( 'last_question' ), submit, end_form, end_html;

In reply to Quiz Game by dooberwah

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.