Try and verify the arguments to perl are making to to the remote system intact. For example, make that substitute operation a string and then print it out. Is it the same version of Perl on the remote system?
You might want to take a look at the File::Remote module. I have never used it but it sounds like it fits your situation.
And the obligatory: You should be using SSH!!
Comment on Re: Search and replace on remote system using rsh