I'm a beginner in Perl, but I think your breakdown of my code explains exactly what I want it to do. I went a little crazy with the escapes though. I'll need the s modifer for some other cases, though it's unnecessary for this example.
I'd like the special meanings of the escaped characters on the right of the s/// to be used. I want the element in which the substitution is taking place
to be referred to when Perl is assiging real text to the special characters.
Not that you're solution is worse than my proposed one, but I was suprised to learn that mine didn't work.