in reply to array of MySQL data for substitution

You are much better off doing all of the regexp at once. Try this:
use Regexp::List; my $l = Regexp::List->new; my $re = $l->list2re(@swearwords);
And then later on in your other loop, do this:
$text =~ s/$re/****/g;