I've found that the easiest way to create comparisons using boolean algebra is to start with them overly simplistic and then slowly bring it together in it's tightest form.

For your search, I would start with
if ($form{searchtype} eq "keyword") { #check that what was filled in +the form was right if ($class =~ /keyword/) { #Check the class is type keyword if ($desc =~ /$form{'searchstring'}/i) { #Make sure the string + is in $desc if ($desc =~ /$form{'searchprice'}/) { #Check for price in + $desc print "$desc\n"; } } } }

Because it is broken down like this, it is easy to see repeats in logic, and what conditionals might be missing. It also eases debugging of the logic, since you can put print statements to see a particular conditional is not working. Now we can use each nested if as an "and" and rewrite it as:
if (($form{'searchtype'} eq "keyword") && ($class =~ /keyword/) && ($desc =~ /$form{'searchstring'}/i) && ($desc =~ /$form{'search +price'}/)) { print "$desc\n"; }

From your question, the above should print desc only when those 4 different conditions are all met.
HTH
Dave

In reply to Re: Search question by dfog
in thread Search question by SysAdm

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.