procmail
[Top] [All Lists]

Logic, DeMorgan's law, and efficiency

2000-08-09 05:04:33

I'm having trouble concentrating and, after puzzling over the below
for about 10 minutes, decided the best thing would be just to ask.

I have a pair of recipes in my spam-snag area that look for
non-Western characters in the From: or Subject: headers.
The recipes work well enough, I believe, though I can't remember
the last time they were triggered.  But anyway, here they are:


  nonWEST="*=\\?gb2312\\?[bq]\\?"  # useful for character-set testing

  :0  # non-Western character set implies spam
  * $ FROM ?? $nonWEST
  { RECIPE = "${RECIPE:+$RECIPE }UBE_03a" }

  :0
  * $ SUBJECT ?? $nonWEST
  { RECIPE = "${RECIPE:+$RECIPE }UBE_03b" }


(I run through various likely spamish scenarios in a dozen-and-a-half
recipes and only assign labels.  At the bottom, the labels are shunted
cummulatively to my logs and also inserted in an X-header in the 
message putatively identified as spam.  The message is then saved
to $SPAMSNAG.)

Anyway, back to the above recipe pair, I've long thought there should be
an easy way to combine the two, though I understand that doing
something like the below on the condition line doesn't work:

  * $ (FROM|SUBJECT) ?? $nonWEST

Apparently, you can't use this kind of OR construction on the
left side of the MATCH-style header egrep.  Okay, fine.

But then it occured to me that, with DeMorgan's Law, I probably
should be able to do this?

        :0
        * ! $ FROM    ?? $nonWEST
        * ! $ SUBJECT ?? $nonWEST
        { }

        :0 E  # else . . .
        { RECIPE = "${RECIPE:+$RECIPE }UBE_03" }


The reason I'm writing is that I seem to have cognitive trouble when
I start reversing conditions by prepending "NOT".  Somehow it befuddles
my brain.  So I want to know if this proposed alternative does the
same thing as the repetitive-looking pair I initially had.  Comments?

-- 
To avoid auto-ack when replying to me, use dman+noacks(_at_)nomotek(_dot_)com

_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>