http://qs1969.pair.com?node_id=519468


in reply to Blocking based on words in a list

i see this construct very often ($scalar =~ @array) but it's totally wrong... you have to check very entry in that blocked-array.
reading all entries into an array can be slow and memory consumming and actually there is not need to use regexp's heer. so i would change the code like this.
if(open (my $filehandle, '<', '/home/cowpensv/public_html/cgi-bin/bloc +k.txt')) { my $comments = $FORM{'comments'}; my $is_blocked = 0; while ($is_blocked == 0 && (my $word = <$filehandle>)) { chomp $word; $is_blocked = 1 if index($comments, $word) > -1; } close $filehandle; if ( $is_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; } } else { die "Can't open block.txt"; # or any other error-handling # i don't like die in a cgi-env }