procmail
[Top] [All Lists]

Efficient use of OR-matches and $MATCH

2000-01-31 07:22:43
First off, Happy New Year 2000, folks!

I have some questions concerning the regexp matching process, and
would like to do it efficiently since I have 1000-2000 messages per
week which get analyzed by the recipe.  I have looked at Jari's
Procmail resources, but did not find what I wanted.

I have a recipe that starts like this:

:0
* 9876543210^0 $ ^(From|Subject):.*\/\<(${regexps})s?\>.*$
* 9876543210^0 B ?? $ ()\/\<(${regexps})s?\>.*$
{
   EXPR = $MATCH

   ...
}

The variable $regexps consists basically of a huge OR-match of mostly
strings, and a few simple regexps, for example:

        regexps = "fee|fie|foe|fum"

I would like the interior recipe, noted as ... above, to consist of
exclusions, think of it has a huge case statement:

#  case 1
   :0 B
   $* $EXPR ?? "fee"
   $* ! fee fie fum
   {
        OKAY = yes
   }

#  case 2
   :0 B
   $* $EXPR ?? "fie"
   $* ! fie.*foe
   {
        OKAY = yes
   }

#  case 3
   :0 B
   $* $EXPR ?? "fum"
   $* ! foe.*fum
   {
        OKAY = yes
   }

   .... #2

# default
   :0
   {
        OKAY = no
   }


Here, OKAY should be true if at least one case succeeds.  Case 2
should be tried if case 1 is not executed or if it fails.  Does it
suffice to add the `e' flag, creating the follwing start line:

   :0 Be

Does the huge $regexp serve any purpose?  Should I just have `k'
independant recipes?  Would this work?  I currently actually have:


:0
* 9876543210^0 $ ^(From|Subject):.*\/\<(${regexps})s?\>.*$
* 9876543210^0 B ?? $ ()\/\<(${regexps})s?\>.*$
{
   EXPR = $MATCH

   <122 * ! ... negative conditions>
}

This is actually overkill, since some conditions depend upon the value
in  (or matches) $EXPR.

Any suggestions are appreciated.

Thanks!

        --Ralph

Dr. Ralph P. Sobek                Disclaimer: The above ruminations are my own.
Ralph(_dot_)Sobek(_at_)irit(_dot_)fr                       Addresses are 
ordered by importance.
sobek(_at_)irit(_dot_)fr
Ph:(+33)[0]561558618   FAX:(+33)[0]561556258   http://www.irit.fr/~Ralph.Sobek/
===============================================================================
Why can't Congress pass Gun Control or decent Health HMO Laws? And East Timor?

<Prev in Thread] Current Thread [Next in Thread>
  • Efficient use of OR-matches and $MATCH, Ralph SOBEK <=