I presume you're trying to replace each string with a specific other string, i.e. XXX is always supposed to be replaced by AAA etc.
my $text="The respondent uses the following products XXX, YYYYYYYYY, Z
+ZZZZZZ around the house and they are considering using QQQQQQQ too. T
+hey are particularly impressed with ZZZZZZZ.";
my %replace=( "XXX" => "AAA",
"YYYYYYYYY" => "BBBBBB",
"ZZZZZZZ" => "CCCCCC",
"QQQQQQQ" => "DDDDDDDD");
my $search=join '|',keys %replace;
$text=~s/($search)/$replace{$1}/g;
print $text;
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. -- Brian W. Kernighan