$val = '123'; while () { s/\$(\w+)/$$1/g; print; } __DATA__ test_string_$val