Darin, something about your problem kept nagging me. Have you considered also keeping an *exceptions* dictionary? This would allow flexibility in adjusting for future problem words without modifying your code. It would also let you handle phrases, and uses two trivial regex's. Something similar to the following:
# exceptions dictionary
our @Exceptions = (
'game cocks',
'gamecocks', #etc
);
# censor dictionary
our @Vulgarities = (
'cocks',
'cock', #etc
);
$censored = censor($post);
sub censor{
# get a copy of the post
my $copy = shift;
# remove all exceptions
for $except (@exceptions){
$copy =~ s/$except//gi;
}
# now check for banned words or phrases
for $vulgar (@vulgarities){
if ($copy =~ /$vulgar/i){
return 1;
}
}
return;
}