procmail
[Top] [All Lists]

Re: Matching the first occurrence of a header field

2002-04-07 12:49:19
At 14:06 -0500 07 Apr 2002, "David W. Tamkin" <dattier(_at_)ripco(_dot_)com> 
wrote:
To check only the second Received: header from the bottom would
probably require forking another program 

Not true.  You can use the fact that procmail will stop matching scored
conditions once it reaches the supremum score to find an arbitrarily
numbered occurence of a header from the bottom.

:0
# The first number here is the header number from the bottom
# which we wish to match (2 in this case)
* 2^0
# Count the total number of the type of header
* -1^1 ^Received:
# Get the score appropriately close to the supremum value
* 2147483646^0
# Now find the right one
* 1^1 ^\/Received:.*
{ LOG="$MATCH" }

If there are less than the desired number of Received: headers $MATCH
will remain what it was before this recipe.

-- 
Aaron Schrab     aaron(_at_)schrab(_dot_)com      http://www.schrab.com/aaron/
 I do not fear computers.  I fear the lack of them.  -- Isaac Asimov
_______________________________________________
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>