procmail
[Top] [All Lists]

Re: how to match against first N lines/bytes of body?

1997-11-14 03:52:11
On Thu, 13 Nov 1997 14:57:48 -0600 (CST),
"David W. Tamkin" <dattier(_at_)miso(_dot_)wwa(_dot_)com> wrote:
But if N=50, to heck with it:
  :0Bi
  toplines=| head -$N # sed ${N}q if you don't have head
  :0a
  * toplines ?? pattern
  whatever

Can't you just do a MATCH grab instead of run an external process? 
The regex to grab fifty lines (or all of them, if there are less than
fifty) is not going to be very pretty, but it should be a lot more
efficient. 

    :0B
    * ^^([      ]*|$)*\/[^      ].*$(.*$)?(.*$)? ... etc, another 47 of'em
    { toplines="$MATCH" }

The skipping of whitespace at the beginning of the message is of
course not necessary or anyhitng. You should probably set LINEBUF
reasonably high (at the very least 80*50 = 4000 bytes; probably
setting it to 8192 or 16384 is a good idea while you're at it) in
order to avoid trouble.

/* era */

-- 
 Paparazzi of the Net: No matter what you do to protect your privacy,
  they'll hunt you down and spam you. <http://www.iki.fi/~era/spam/>