in reply to existence of a file on remote host

Not seeing any code, nor any more detailed spec, I can only suggest again Net::SFTP, as I did yesterday in Re: append an expression to a file on remote host.