in reply to parsing code, finding block boundaries

I thought about using substr as an lvalue, but I don't know of any way to insert new text without overwriting existing text.

The obvious way works ...

substr($code, $end, 0) = "}"; # -OR- substr($code, $end, 0, "}");