This is somewhat off-topic for perl, but you could look at "ssh-keygen" to generate a key pair, to allow for automated authentication keys. This should prevent sftp from asking for a password.
...it is unhealthy to remain near things that are in the process of blowing up. man page for WARP, by Larry Wall
Comment on Re: Need help in doing SFTP via command line