1/ Using a string eval to speed-up is non sense. String eval means that you must recompile each time you hit the eval at run-time.

2/ you code is basically:

sub { return 1 if m!foo!o; return 0 }

this can be simplified to

 sub { m!foo!o }

Not only this returns a boolean value but at no extra cost the list of strings matched in parenthesis if there are like the rest of your post implies. In that later case, the boolean value is obtained indirectly because in scalar context, the list is converted to its length. This leads me to 3/

3/ now about $match = qq@  return (\$1,\$2) if m!(foo)(bar)!; @; As I said the match operator returns directly the list of matches so you don't need to return explicitely $1, $2...

I really don't understand what you want to do. But I am sure your way of doing it is certainly incorrect.

Edited: suppressed inaccurate remarks. Thanks to chipmunk for pointing out my mistakes.

-- stefp


In reply to Re: eval routines for faster regexp: how-to... by stefp
in thread eval routines for faster regexp: how-to... by gleeco

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.