while ($input =~ s/(.*?)(<.*?>)//) { $w=$1; $q=$2; 1 while $q =~ s/(--.*?)-(.*?-->)/$1¬$2/sg; $output .= "$w$q"; }