in reply to running script within a script (semi-interactive)
Have you tried the perlipc manpage?
The section headed Safe Pipe Opens (about a third of the way down the page) may provide a solution.