procmail
[Top] [All Lists]

Re: scoring

1997-06-07 12:02:00
Vincent Lefevre asked,

| For instance, I have a recipe for the header and a recipe for the body,
| and I'd like to perform some operation if the sum of both scores is
| positive.

Ideally, you could use "H ??" and "B ??" modifiers on the individual condi-
tions, combine them into one recipe, and let procmail total the scores:

  :0 flags
  * w^x H ?? whatever
  * w^x H ?? whatever
  * w^x B ?? whatever
  * w^x B ?? whatever
  * offset_if_needed^0
  action_if_total_score_is_positive

Sometimes, however, you aren't able to do that.  For example, on another site
I have a problem with nulls being inserted into my mail, and I want separate
figures for the body and the head, so I need separate recipes (the "^@" is
shown as caret+at in this post, but in my .procmailrc it's an actual null
character).

  :0 # H is implicit
  * 1^1 ^@
  { NULLSINHEAD = $=
    LOG="There were $NULLSINHEAD nulls in the head.
"   }

  :0B
  * 1^1 ^@
  { NULLSINBODY = $=
    LOG="There were $NULLSINBODY nulls in the body.
"   }

  :0fw # the tr there is null-impaired and will lose nulls from the input
  * $ ${NULLSINHEAD-0}^0
  * $ ${NULLSINBODY-0}^0
  | tr

But if I wanted just to know how many total nulls there were, this would
do the job:

 :0HBfw
 * 1^1 ^@
 | tr
  :0A
  { LOG="There were $= nulls in the message.
" }

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