in reply to Better Way of Manipulating Array Elements

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:

  1. Replace "d" only if an array element is "d" - that is, "abcded" should remain as is.
  2. Any "d" in any array element should be replaced with "newd", so "abcded" becomes "abcnewdenewd".
  3. Only the first "d" in any array element should be replaced with "newd", so "abcded" becomes "abcnewded". This is what your current code does.
  • Comment on Re: Better Way of Manipulating Array Elements