procmail
[Top] [All Lists]

Re: procmail as sendmail filter

2000-02-07 16:20:31
2000-02-07-17:34:55 Andrew Edelstein:
2000-02-06-16:26:08 Philip Guenther:
If you want the size of just the body, then qualify the
condition:

    :0
    * B ?? 1^1 > 1
    { }
    SIZE = $=

This may solve a problem I've been working on. If I can just grok
how this works so I can fit it into my application...

Lemme see if I can assist with the grokking; I love trying to
explain this stuff, if I succeed, I may even end up understanding it
myself (and I am keen to understand this; I've gotta understand it
pretty darned well eventually, since I hope to write a translator
that can read the above line noise and emit something suitable for
humans:-).

Most of the above recipe is simple. The first line is a trivial
start-of-recipe, the last one is a normal variable assignment
(assigning the value of the $= variable, which is the accumulator
for the scoring code). And the next-to-last line is a null block,
an empty action, to fill the mandatory "action" part of a recipe.

That leaves the nice clear

        * B ?? 1^1 > 1

Well, the * is just the thing that preceeds all lines between the :0
and the action, marking it as a conditional. Then the "B ??" is
explained by the section of procmailrc(5):

       There are some special conditions you can use that are not
       straight regular expressions.  To select them, the  condi-
       tion must start with:
                ...
       variablename ??
            Match the remainder of  this  condition  against  the
            value of this environment variable (which cannot be a
            pseudo variable).  A special case is if  variablename
            is equal to `B', `H', `HB' or `BH'; this merely over-
            rides the default header/body search area defined  by
            the initial flags on this recipe.

So saying

        :0
        * B ?? ...
        { }
        SIZE = $=

is an alternative way of writing

        :0 B
        * ...
        { SIZE = $= }

So let's keep nibbling away at the line noise in ...

In procmailsc(5) I find that the pattern w^x > L is _extra_ special
voodoo, that does length-weighted scoring; it computes w*(len/L)**x.
Since all the numbers here are 1, this is just the natural way in
procmail to say "set SIZE equal to the length of the body", in one
direct step.

If someone told me that

    :0
    * B ?? 1^1 > 1
    { }
    SIZE = $=

were the most natural and reasonable way to set SIZE equal to the
size of the object a tool is designed to manipulate, and if the tool
in question were Intercal, then I'd laugh aloud and say "_Cool_!".
If however the tool were not Intercal, I'd suggest that this may be
some misplaced humour; the correct place for such humour is
intercal, and please let's keep it there.

-Bennett

Attachment: pgp63RYI90igd.pgp
Description: PGP signature

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