use Regexp::List; my $l = Regexp::List->new; my $re = $l->list2re(@swearwords); #### $text =~ s/$re/****/g;