in reply to array of MySQL data for substitution

use strict; my @swearwords = qw/bad worse ugly/; my $text='This is a bad sentence with some ugly and worse words'; $text=~s/$_/****/ foreach @swearwords; print $text;
works nicely for me, so the error is not in the regex.

Perhaps you should do  while (my $text=$sth->fetch) so you have at least a text to work on!

<Update: Or you could do away with the foreach loop as follows:

use strict; my $swearwords= join '|', qw/bad worse ugly/; my $text='This is a bad sentence with some ugly and worse words'; $text=~s/$swearwords/****/g ; print $text;

CountZero

"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law