NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
and and and not (Score:2)
(A or B) and ( (C and D) OR E )
You could use chaining, but you'd need
two objects in the above, and the logic
might be clearer is you just had an AND
you may want to include both OR and AND and NOT as well
because some folks will find it easier to compose
(A or B) and NOT( C or D or E)
than
(A or B) and ( NOT C and NOT D and NOT E)
...especially when C, D, E may be moderately complex.
Maybe that's overkill though.
To ensure overkill, also include methods for those who
think in terms of set operations (Union, Intersection,
and Difference). These could just be different names
for the same code.
Union(A,B) => A OR B
Intersect(A,B) => A AND B
Difference(A) => NOT A
going off the deep end, you could overload some operators
Union(A,B) => A OR B => $queryA + $queryA
Intersect(A,B) => A AND B => $queryA * $queryB
Difference(A) => NOT A => !$queryA
The result of each of the above would be a new query object.
Heck, you could throw in subtraction while you're at it
$qc = $qA - $qB # C = A AND NOT B
time to stop rambling
-matt
Reply to This