procmail
[Top] [All Lists]

Re: PERL within .procmailrc

1999-07-27 18:17:12
At 01:19 AM 7/25/99 , Glen Lee Edwards wrote:
I'm trying as an experiment to create a recipe that pipes all incoming
mail to PERL to modify the subject line to add in a list id [naztalk].
Following is what I'm using:

What you have is a perl error.

:0 fw: mstst.lock
| /usr/local/bin/perl -e "s/(Subject: )(.*)/\1\[naztalk\] \2/"

Perl is not doing anything. Your code tells perl to substitute, but doesn't give it anything to work with. you need something more like this:

| /usr/local/bin/perl -e "while(<>){s/(Subject: )(.*)/\1[naztalk]\2/;print}"

ie: while (<>) { # while there is input
        s/(Subject: )(.*)/\1[naztalk]\2/; # Substitute
        # \[ and \] are not needed in the replacement string
        # actually this can be simplified to just
        # s/Subject: /Subject: [naztalk]
        # eliminating the overmatching and memory..
        print; # print the contents of $_
}

HTH,

jon

--
Jonathan J. Miner----------------------|        
miner(_at_)doit(_dot_)wisc(_dot_)edu
Network Systems Technology             |               608/262.9655
Division of Information Technology     |      3149 Computer Science
University of Wisconsin, Madison       |         1210 W. Dayton St.

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