I think what you really want is either to use something like String::Interpolate, or a templating system. For the latter, see a nice intro in this 4 part article, though I'm sure lots of people here have their own favourite templating system, and are willing to let you know about it.
You're a god. You've managed to answer two questions, one of which I haven't got around to asking.
So that's what it's called Interpolate.... That's why it's such a pain to find answers sometimes, I don't the name of what I want to do.