http://qs321.pair.com?node_id=414735


in reply to changing a portion of a line leaving its formatting intact

This sounds like a textbook case for using a template.

Text::Template