[Mimedefang] Code fragment works only sometimes

Andrea Venturoli ml.ventu at flashnet.it
Mon Jul 14 16:17:01 EDT 2003

** Reply to note from Joseph Brennan <brennan at columbia.edu> Mon, 14 Jul 2003 10:25:08 -0400

Thanks a lot for your suggestions.

> 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(). 

Ok, I've tried these two. Since I'm not a perl guru, I've reported my code once again. Could you please give it another

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

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

For now it doesn't look as if it is needed, but just in case how would I do that?

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

Sorry, I didn't understand this. Which newlines? Why?

Another possible improvement would be to read BLK only once, not for each message I parse. Can I do this? How?

 bye & Thanks

More information about the MIMEDefang mailing list