Where did you see that setcwd() or size() were valid methods in
Net::SFTP (Update: You need to call one of the stat methods which returns an attribute object which you can call size() on)? I'd recommend
Net::SFTP::Foreign over Net::SFTP anyway. But make sure you read the docs and only call methods that exist.