procmail
[Top] [All Lists]

Re: Scoring by size ???

2003-09-27 09:45:55
Michael Schleif has this code (I was hoping someone else would answer this, because I'm not feeling so great lately, but nobody has, so he reposted, and I'll handle it),

:0
*  -2^0
*   1^0 > 240000
*   1^0 > 140000
*   1^0 < 165000

with an action line that he didn't tell us.  He observed,

Now, in my logs I get this:

procmail: Score:      -2      -2 ""
procmail: Score:       1      -1 "> 240000"
procmail: Score:       1       0 "> 140000"
procmail: Score:       1       1 "< 165000"

Well, you raise any real to the power 0, you get 1.

What am I missing?

You're missing the experience of having read the procmailsc(5) man page, I'd suppose. You saw something about the way scores work on regexp conditions and tried to get the same results from size tests.

How can a message be *both* > 240000 bytes _AND_ < 165000 bytes?

That's not what putting a score on a size test condition means. On a search area (default HB, regardless of the flag line) of size S bytes,

 * w^x > T

scores w*(S/T)^x, and

 * w^x < T

scores w*(T/S)^x, so if x=0, the score is w regardless of the length of the message.

The question is, how do you score w if the message is under/over a given size and 0 otherwise? It takes a compound recipe. First, get the size of the message into a variable:

 :0 # condition scores 1*(size/1)^1
 * 1^1 > 1
# * -1^1 > -1 works too if you're weird enough to use it
 { SIZE = $= }

(It's customary to save scores outside the braces in case the score is non-positive, but that can't happen here.) Now to see if it's smaller than 240000 and larger than 165000, here's one way to go:

 :0
 * $ $SIZE^0
 * -165000^0
 { }
 :0A
 * 240000
 * $ -$SIZE^0
 action_if_in_165001-to-239999_range




_______________________________________________
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>