in reply to How to pass data as STDIN to Capture::Tiny
You might find some useful ideas in this 2009 thread: Catching STDIN and STDERR on the fly.
Hope that helps,