in reply to Substitution in text files

s/\$subKey/$subVar/

replaces the literal '$subKey' with $subvar. What you might have wanted is

s/$subKey/$subVar/

____________________
Jeremy
I didn't believe in evil until I dated it.