in reply to Bad Language In Contact Messages

There are various modules regarding profanity on CPAN

Like https://metacpan.org/pod/Regexp::Profanity::US

So you don't need to implement your own solution.

More general you might need a generic spam word solution, e.g. "Nigerian prince" is not really a profanity as such... ;)

On another note:

I'm not sure if returning a detailed error message is a good approach against spammers, they might use it to train against your filter.

So at least consider a JS based feedback, to make it harder to be spotted by bots.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery