procmail
[Top] [All Lists]

Re: How to handle "psudo-headers"?

1996-09-24 17:44:02
Michael C. Tiernan <mtiernan(_at_)bbn(_dot_)com> wrote:

[snip]

 > The relevant information is . . .
 > Entry-number: nnn
 > Subject: {different subject from above}
 > Description: {multi-line description}
 > Applies-to: {keyword}
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
      There's this psudo-header "Applies-to:" that I'd like to key a
      response from but I'm a little unsure of some of the dangers of
      trying this so I thought I'd ask the list.  I can do perl, shell,
      or procmail/formail itself as processors of this and I'm
      wondering what people would suggest as a solution.

Not very familiar with perl syntax, so I'll suggest an awk solution and
you can rewrite in perl if you choose.

        :0 b
        APPLIES_TO=| awk '/^Applies-To: /{print $2;exit}' -

For a little more robustness:
        :0 b
        APPLIES_TO=| awk '/^Applies-To: /{ \
                if(NF>1) {print $2; exit}} \
                END {print "didnt_find_applies_to"}' -

(These are untested.)

Hope that gets you a start; what you actually want to do will depend
on what you expect from your "Applies-To:" pseudo-header and how
you want to deal with erroneous mail.  The above will get you
a $APPLIES_TO variable you can then use.

Cheers,
Stan Ryckman (stanr(_at_)tiac(_dot_)net)

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