Tcl Exec Sed, The right tool is at hand, and is far more efficient (given that you're already in Tcl).