I've been given a task to write a perl script that can update a file containing system names on a remote system. This file is of critical importance for an application running on the remote system, so I want to make this thing as bulletproof as possible. I'm looking for any suggestions as to the best way to do this.

I have SSH authorization keys already in place on the local and remote system, and the Net::SSH and Net::SCP modules to interact with SSH. What do you think is the best way to do this? Should I pull the file down first, modify it, and then push it back, or should I try to modify it on the remote server directly? Any other pitfalls I should be wary of?