While strongly endorsing the string templating approach, there is also a discussion of this double-quotish nested string interpolation stuff in
Evaluating $1 construct in literal replacement expression and along the links from the reply
Re: Evaluating $1 construct in literal replacement expression.