procmail
[Top] [All Lists]

Re: Extracting substring from formail -rzx "To:"

2004-06-29 18:35:24
Toen wij Lee Hoffner kietelden, kwam er dit uit:

perl script, which is matching $ADDRESS to a MySQL db
that contains only email addresses without names.

This seems easy to do in procmail too. Even without fgrep. 
Saves tons of cycles.

Everytime the db is changed, recreate files with all 
the clean addresses. Put in file 'CLEANFROMS_a.inc' 
all the addresses that start with an 'a', etc. 

These files are to be included by procmail, so make 
them look like:

CLEANFROMS = "
aaa(_at_)something(_dot_)com
abracadabra(_at_)another(_dot_)com
acad(_at_)else(_dot_)com
"


The recipe then becomes:

  :0h
          CLEANFROM = `formail -IReply-To: -rtzxTo:`

  :0  # get 1st letter
  * CLEANFROM ?? ^^\/.
  { CHAR = $MATCH }

  LCASE = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz"
  :0D  # convert to lowercase
  *  CHAR  ?? ^^[A-Z]^^
  *$ LCASE ?? $CHAR\/.
  { CHAR = $MATCH }

  CLEANFROMS # unset
  INCLUDERC = "CLEANFROMS_$CHAR.inc"

  :0
  *$ CLEANFROMS ?? ^$CLEANFROM^
  { etc. }

(untested)

If the largest file becomes > 32K or so, it is time to switch to a 
doublechar-system (or to fgrep).

You might need to adjust LINEBUF to the size of the largest file, 
but I am not sure.

-- 
Grtz, Ruud

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail