[Mimedefang] Code fragment works only sometimes

Joseph Brennan brennan at columbia.edu
Mon Jul 14 10:26:01 EDT 2003

>     if
> (open(HDR,"HEADERS")&&open(BLK,"/usr/local/netfence/local/etc/spam_recipi
> ents"))     {
>         @lines=<HDR>; @blk=<BLK>;
>         foreach $line (@lines)
>         {
>             foreach $blk (@blk)
>             {
>                 if (rindex($line,$blk)!=-1)
>                 {
>                     md_log($line);
>                     return action_bounce("Spam is not accepted");
>                 }
>             }
>         }
>     }

Make sure you close() those files before you return, or you're
going to accumulate lots of open filehandles.  Since you're
stuffing the data into arrays, why not close right after that,
before the first foreach statement.

Clear the variables when done, or make them local with my().

You could lowercase everything before comparing, so it's not
case-sensitive, if that's desirable.

Do chomp($blk) each time to get rid of the newlines.

Joseph Brennan         Columbia University in the City of New York
Academic Technologies Group                   brennan at columbia.edu

More information about the MIMEDefang mailing list