Looking at the code excerpt you have posted, it seems unlikely that you need the 256 files opened simultaneously. Probably, your code or some of the modules you are using or the OpenSSH binary is leaking file descriptors in some way.
Increasing the available file descriptors is just going to hide and delay the issue but not to solve it.
Net::OpenSSH has a debug mode you can enable setting $Net::OpenSSH::debug=-1, and you can also pass the flags -vvv to the ssh client in order to find where your program is failing.