Don't use \1 in the replacement part. It's a kludge, ambigious, only works for small numbers, may no longer work in a future version of Perl, will warn when warnings are enabled, and will mark you as an old perl4 programmer who is having sed-withdrawal syndromes.
As for substituting "d", do you mean:
- Replace "d" only if an array element is "d" - that is, "abcded" should remain as is.
- Any "d" in any array element should be replaced with "newd", so "abcded" becomes "abcnewdenewd".
- Only the first "d" in any array element should be replaced with "newd", so "abcded" becomes "abcnewded". This is what your current code does.