in reply to
How can I pass an open session of Net::SSH2 to a script running in a forked subprocess?
I'd be interested in seeing your script as I have tried a basic SSH client with Net::SSH2 and have gotten into (unresolved) problems with input/output - see Net::SSH2 command output polling.
Because fork creates a copy of the environment, you can't "share"* variables between the parent / child without some form of inter-process communication. This I am not an expert on so will watch the forthcoming answers with interest.
* Update follows to reflect blue_cowdawg comments in Re^2: How can I pass an open session of Net::SSH2 to a script running in a forked subprocess?:
The same variable in parent and child are actually copies, not the same variable in memory, so when either the parent or child modifies its copy, the other (child or parent) is not aware of the update and the same variable NAME is now 'out of sync' (no longer the same VALUE) between the parent and child.