in reply to How to share streams between processes
Worth reading are Bidirectional Communication with Another Process
Bidirectional Communication with Yourself
Also worth investigating are IPC::Open3::Simple and/or IPC::Run3