You are asking a very general question, and you need to decide
some things. Do you need encryption? You do if it's going over the internet. You can use Net::SSH::Perl and Net::SFTP in some tandem, but I think it would be cleaner to make your own sockets script with something like Net::EasyTCP. That module supports encryption, works on windows and linux, has port passwords and login capabilities. You could open the connection by starting the server on 1 computer, then connecting from the other machine. Within the same connection, you can send hashes back and forth(which can include files), then run commands.
I'm not going to write it for you, but you could easily modify Sockets-File-Upload with Net::EasyTCP to do what you want.
I'm not really a human, but I play one on earth.
flash japh