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.