Ok, I've been playing with this for hours. I'm not a trained programmer, so what I've learned so far is by trial and error. Please bear with me.
I have a guestbook that someone has been spamming recently. I simply want to create a list of words in a txt file that can be assigned to a variable. Then when the user clicks submit, it checks to see if the comments field contains any of the blocked words in the list. If so, it simply posts a message saying BLOCKED!!. If not, it allows the user to post.
Here's the code I've been playing with. Someone please have a look at it and tell me where I'm going wrong. I can get it to work if I specify the exact word in quotes where you see "@blocked" below in the IF statement. I've tried various combinations of quotes, using $ instead of @, using "eq" instead of =~, and God knows what else. It either blocks nothing, or blocks everything, regardless of the value of $comments.
Here's my flawed code.
# Check for blocked text
open (BLOCK,"/home/cowpensv/public_html/cgi-bin/block.txt")|| die "Can
+t Open block.txt";
@blocked = <BLOCK>;
close (BLOCK);
if ( $FORM{'comments'} =~ @blocked ) {
print "Content-type: text/html\n\n";
print "<html><head><title>Blocked</title></head>\n";
print "<body><h1>BLOCKED!!</h1>\n";
print "\n</body></html>\n";
exit;}