for my $word (@search_words) { $html =~ s/($word)/$1<\/u><\/b>/g; }