Obviously you have invested some time on Expect so I do not want to steer you to a different solution but just to keep in mind, POE offers excellent solutions to these kind of problems.
You can have a look at POE::Wheel::Run . It will allow you to register callbacks for STDIN and STDOUT so that you can talk to your process in a nonblocking fashion.