Subject: Regular expression questoin

From: Anu Garg <[email-masked]>
Date: Tue, 24 Jan 95 18:27:55 EST

Greetings.

Has anyone used the Procmail regular expression \/ ?
I'd like to see an example of its use.

In any case, this is what I want to do and I think it
can be accomplished using the above:

Take the subject line of the message as a command e.g.
	Subject: define acclaim
and pass the argument (acclaim) of the command (define)
to a script, which returns the sender the definition
of the word. Passing whole subject to the script is no
problem, the question is how to extract the string (acclaim)
after the command (define) inside Procmail.

One more question: In the man page for procmailrc (page.3)
flag f is described as "consider the pipe as a filter."
What does that mean?

Thanks.
Anu

---

From: Rory Murtagh <[email-masked]>
Date: Tue, 24 Jan 1995 21:17:05 -0600

> I'd like to see an example of its use.
Here's my humble example:

:0: 
* !^Subject: .*
* B ?? .*\/^[^ ]+[ ]+[^ ]+[ ]+[^ ]+[ ]+[^ ]+
| formail -a"Subject: $MATCH" >> $ORGMAIL

It's supposed to make up a subject from the first 5 words in a message
text if none was given.  This works but maybe people on the list can
make it "even better".

The regular expression after \/ gets put in $MATCH which you use later.

One thing though -- make sure you are at 3.10.  I wasted an hour
scratching my head wondering what was wrong when all the while I was
running 3.6.

 > flag f is described as "consider the pipe as a filter."
My guess is the pipe is "applied" and the altered messages goes on into
the next rule.  But that's only my guess.

- rory

P.S.  I enjoy your word-a-day server.

---

From: David Meyer <[email-masked]>
Date: Wed, 25 Jan 1995 00:16:19 -0500 (EST)

> I'd like to see an example of its use.

I have a perl script that parses a particular newsgroup and mails me each 
article by certain author(s) (e.g. Larry Wall in comp.lang.perl).  Each 
article has all the original headers, plus a header line "X-Loop-Mailnews: 
comp.lang.perl".  My recipe for this is

:0
* ^X-Loop-Mailnews: *\/[^ ]+
{
    NEWSGRP="$MATCH"
    :0cfh
    | formail -I X-Loop-Mailnews: -I Path:

    :0
    * ? test "$NEWSGRP" = "clari.feature.dilbert"
    * ^mime-version:
    {
        :0cw
        | (munpack -q -t -f -C News/dilbert >/dev/null 2>&1; chmod a+r News/dilbert/*)
        :0a
        { LASTFOLDER=dilbert HOST=done }
    }

    :0:
    Mail/$NEWSGRP.mail
}

This recipe also shows an example of the second question.  The first part
of it, ":0 fch", sends the header through formail, which removes the Path: 
and X-Loop-Mailnews: headers for cosmetic reasons.  Then check for 
special case newsgroups and take care of them; finally, stow the message 
in, e.g., Mail/comp.lang.perl.mail.

One question I have - is the "c" in ":0 fch" useful at all?  I must have 
had a reason to put it in, but I don't know what it was.

		Dave

-- 
David M. Meyer                             Mechanical & Aerospace Engineering
[email-masked]          University of Virginia
NeXTmail ok

---

From: Roman Czyborra <[email-masked]>
Date: Wed, 25 Jan 1995 12:27:24 +0100 (MET)

> Has anyone used the Procmail regular expression \/ ?

Sure, all the time.

> In any case, this is what I want to do

	:0 fhw
	* ^Subject: \/define [a-z]+
	| formail -r

	:0 afib
	| webster $MATCH

	:a
	! -t

If the subject is of the form define something, an autoreply header is
generated.  The fh flags mean pipe the original header to formail -r and
replace it with the filtered output.  The fib loads the output of the
dictionary lookup into the body, replace webster with your own command. 
$MATCH is the string that matched the expression behind \/, i.e. the
request.  Finally you have a new message header and a new message body and
the entire thing can be sent to the recipient listed in the header. 
That's what sendmail's -t option is for.