$htmlbuffer =~ s{>(.*?)<} { my ($mydata) = ($1); $mydata =~ s/abcd/efgh/gs; $mydata =~ s/yyy/zzz/gs; “>$mydata<” }exgs;