The reason your regular expressions don't work is that you are using them wrong.

The perlre manpage (use perldoc perlre to view it) gives a short introduction to regular expressions and how to construct them.

Here's a short attempt at a hands-on introduction geared towards your problem :

A regular expression that matches a single character is /f/. This one would match barfoo.

A regular expression that matches a sequence of characters is, for example, /foo/, which would match barfoobaz, but which would not match barfobaz, because the second o is missing.

To now construct a regular expression that matches one character out of a set of characters, we neet to look at the set constructors for regular expressions, [ and ]. The characters between [] in a regular expression will match any of the characters in a string. So our above examples could be rewritten to /[f]/, which would still only match the letter f, and /[f][o][o]/, which will first try to match the set containing only a f, and after that an o and after that another o. But that is not what you want. You want to match (for example), the string ab. To that, we extend the set from containing one character to two characters : /[ab]/ will match (for example) afoo and bar and zob.

So you will want to construct from the answer data a regular expression and collect all correct answers in a []-set, and match the string against that RE.

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: 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.