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

this assumes your filenames consist only of a-z, A-Z and _ (which is the meaning of \w) and numbers 0-9 (which is the meaning of \d).

oneliner: replaces all orrcurences in "infile" and leaves "infile.bak" with the original contents.
perl -npi.bak -e "s:([\w\d]+\.data):testname/$1:g" infile
or as a script:
use strict; $testname="replacement"; open IN, "infile" or die $!; open OUT, ">outfile" or die $!; while ( <IN> ) { s:([\w\d]+\.data):$testname/$1:g print OUT $_; } close IN; close OUT;
Update:
As borisz /msg-ed me, \w includes \d. thus [\w\d]is equivavelent to [\w].

holli, regexed monk