procmail
[Top] [All Lists]

Re: Thanks!

1997-08-13 22:42:00
Note the Cc: back to the list. 

On Wed, 13 Aug 1997 17:33:34 -0400 (EDT), Niketan Pandit
<darshika(_at_)omicron(_dot_)pair(_dot_)com> wrote:
:0B
* \/(abcxyz|thistext)
{ INCLUDERC=$MATCH }
It is just that now I do not know where and how
do I define $MATCH?

RTFM. It gets defined to whatever matched. That's what the \/ does. As
David and Philip correctly pointed out, Procmail doesn't like leading
backslashes, so you have to change that to ()\/(strings|to match)

I expected that by asking procmail to use only
one INCLUDERC from several (possiblely up to a
couple of hundred), I might shorten processing
time for every incomming mail and reduce load
on the syste. Particularly if it does not have
to scan the entire .procmailrc file.

If you don't want the rc file to always be the same as the string that
matched, you can of course try to set up a mapping of some sort. I've
been playing with that idea lately. Something like, set up a file like
this: 

string1 rc.one
string2 rc.one
string3 rc.two
string4 rc.one
string5 rc.three

and then when you get a match, somehow fetch the corresponding rc file
from this mapping. Here's one approach: 

    :0B
    RCFILE=`tr -c "-A-Za-z'" '\012' | sort | join -o 2.2 - mapping.file`

    :0A
    { INCLUDERC="$RCFILE" }

This is completely off the top of my head and certainly requires a bit
of experience with shell programming. It's also not particularly low
in overhead, but if you have lots of cases you want to handle with a
manageable piece of code, this might be something to start with. 
(join is a PITA because it requires input to be sorted. You could
probably replace the whole backtick expression with a simple awk or
Perl script and get better performance.)

/* era */

-- 
Defin-i-t-e-ly. Sep-a-r-a-te. Gram-m-a-r.  <http://www.iki.fi/~era/>
 * Enjoy receiving spam? Register at <http://www.iki.fi/~era/spam.html>

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