in reply to parsing a txt file
The simple way to do it is one that makes sense when you look at the code again in 3 months, not the one that uses the fewest characters or lines of code. I think the only way to do it with just a single s/// involves some ugly lookahead/look behind stuff, and would probably run very slowly.