I guess you mean /[ad]/. If we look at what I wrote above, /[ad]/ will match any string that contains either an a or a d, which is not yet exactly what you want.

My advice is that you don't need regular expressions at all, since the set of correct answers can be constructed as a string, for example ad, and the set of given answers can be concatenated to a string as well. Checking whether an answer is correct in total is then just a matter of comparing two strings for equality. But first, we need to take a look at the CGI documentation for checkboxes. The example there tells us how to get the checked boxes, so now all we got to do is to concatenate these into one string and compare them against the correct answer :

my @selected_answers = param('s1'); my $correct_answer = join( "", @selected_answers ); if ($given_answer ne $correct_answer) { print "Bleh ! You lose !" } else { print "Yay ! Correct !" }

A small side note - you are not using the strict module. This is very bad and will hide many programming errors from your eyes. So please use strict; !

perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web

In reply to Re: Re: Re: Match function not providing results by Corion
in thread Match function not providing results by chriso

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.