Slash Boxes
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

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • by wickline (135) on 2002.07.19 13:25 (#10883) Journal
    You need both OR and AND for sufficiently complex queries...

        (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)
        (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 :)