in reply to ho w to replace a occurence of string by other string

untested:
perl -pe 's:(\w+\.data)\b:testname/$1:g' <input >output
Boris