There are probably better places, such as IRC channels, to get handholding through Unix shell exercises. While there are many people from many backgrounds with deep knowledge in many things, it really is Perlmonks, not Sshmonks. No offense.
Actually, this has nothing to do with ssh either... it's just a Unix problem. You are trying to redirect the output of cat into a directory. If you copied the file, cp would know the input file name and could use it to create the output file. Redirection with ">" doesn't do that... you have to tell it the name of the file explicitly. I think you can just change:
Hmm... you have the same file name on both systems... remember to back up the file to a different name in case the rm ever gets executed on the wrong one. Even better, change the name on one system or the other.
Another, possibly simpler, approach would be to just have perl execute its own standard input, so you don't need to use a temporary file at all,
hi guys... this what i did... i first setup the ssh public and private keys for the 2 servers... so that the passwords are not typed... and then wrapped it in a shell script and ran it on the server i am workin on...
for setting up ssh keys... SSH Setup