Funny you should ask this now, as I just saw a very similar question on StackOverflow but for PHP, yesterday (posted 23 hours ago). Do you, by accident, know each other?

Anyway, what I'd think of is to store a simple expression, as text, in the database. You could do it in Perl and use eval. Or, my preference, you could write the expressions in a simpler language (which first of all doesn't have the '$' for the variables) than Perl, for example Javascript (and C and ... zillions of other languages), possibly even extended. For example your code could better, IMHO, be rewritten as:

a eq "A" && p in (88, 89, 90, 91)

Then all you have left to do is write a simple expression parser/evaluator, and I just happen to have written one, once. I've even converted it to Perl, here: Operator Precedence Parser. I see it doesn't parse functions (with parameters) (yet), which would be useful for implementing in(...), but that's not too hard to add. I might do that as an exercise, later today. <pEdit When I think about it, using/parsing "in" as a function is not right: it's actually an operator with a scalar on the LHS and a list on the RHS. A function with arguments would look similar, but would be used in a different position (as an expression instead of as an operator) so it ought to be parsed, and processed, differently.


In reply to Re: Conditional Elimination by bart
in thread Conditional Elimination by dunnyman

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.