in reply to search replace (interpolation)
You're essentially filling out a template, so why not using one of the many template modules available at CPAN? Personally I'd use Text::Template for a job like this.
Just my 2 cents, -gjb-