in reply to STDOUT, STDERR sniffer

This question - and variations on it - is frequently asked. IO::Capture is your friend.