in reply to Multi-line Regex Performance

Your regex is awfully slow. That's what it comes down to. You're inching forward character-by-character until you come to '##' or the end of the string. The regex could be made amazingly faster by just making this one change:
$str =~ /(##(?:.*\n)*)(?=##|\Z)/g
That reads "lines" at a time until it gets to '##' or \Z. Another way you could write it (to be very fast) is:
$str =~ /(##(?:[^#]+|#[^#])*/g
That doesn't even need the look-ahead.

Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart