$content =~ s/(<script)(.*)(\/script>)/$sDelimStart$scriptCount$sDelimEnd/si;
---------------
my $data = "<script(small script)/script>;
$data =~ (your substitution here);
print "result: " $data;
result: (the bad output)
---------------
Also, the s modifier causes the input to be treated as a single string - . matches \n.
The .* is greedy and will eat as much as it can - if you have more than 1 script block, it will eat from the start of the first to the end of the last. Use .*? for the non-greedy version. But it seems you only have one script block.
Another regexp higher in the script was munging the HTML data where the parenthesis resided. I was trying to do a s/xx/yy/ replace on various combinations of \r\n to account for different formats of HTML files and apparently escaped the parens on a couple of atoms by mistake. So, thanks again.