you again open the file in write mode to write in the test.txt file.
open (FIN, "test.txt")|| die ("test.txt does not exists");
undef $/;
$instr = <FIN>;
open (FOUT, ">test.txt")|| die ("test.txt does not exists");
$instr =~ s|/prj/sw/tool|/prj/vlsi/toolsmodule|si;
print FOUT "$instr";