This is actually a shell question, not a Perl question.
You need to escape the slashes in the filename, otherwise the shell will interpret them as escape sequences.
What you have right now:
$ echo "s/Else/Else FILE_WRITE(\"C:\TestDir\mes.txt","Message received");/g"
bash: syntax error near unexpected token `)'
What you want:
$ echo "s/Else/Else FILE_WRITE(\"C:\\TestDir\\mes.txt\",\"Message received\");/g"
s/Else/Else FILE_WRITE("C:\TestDir\mes.txt","Message received");/g
In the future, try to use single quotes instead of double quotes. Then you can write without escaping:
$ echo 's/Else/Else FILE_WRITE("C:\TestDir\mes.txt","Message received");/g'
s/Else/Else FILE_WRITE("C:\TestDir\mes.txt","Message received");/g
Perl's flexible q and qq operators are also helpful:
$ perl -e 'print q{A double quote looks like this -> "}'
A double quote looks like this -> "