procmail
[Top] [All Lists]

piping to perl

1997-09-12 14:43:59
I'd like to use the following perl script to read a message body and
return true or false depending on the program outcome. I have a few
questions on how to do this and would appreciate any advice on how to
optimize the script. 

The idea is to define spam by multiple occurences of $, while ignoring 
any message that is perl or procmail related. (Would it be more efficient
to check for (perl|procmail) before going to the perl script?)

#!/usr/bin/perl5
$count=0;
$brackets=0;
while (<>){                      --> will <> handle the input from procmail?

        $count += s/\$/\$/g;     --> counts occurences of $ in a message
        $brackets += s/\{/\{/g;  --> counts occurences of { in a message

        if ($_=~/(perl|procmail)/i){ --> if perl or procmail occur 
                                        any where in message then exit
                                        with a status of 0
                 exit(0)
        }
}
if (($count > 5) && ($brackets < 2)){exit(1)} --> more than 5 $'s with 1
                                                or less { then exit with 
                                                status of 1
exit(0);

----------

Would this be the recipe?

:0Bf:
? | perlscript
spam

______________________________________________________________________________
Joel Bremson                       #         www.wenet.net
Whole Earth Networks               #         www.wenet.net/well
Team Leader                        #         www.wenet.net/hooked
staffjb(_at_)wenet(_dot_)net


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