I hadn't thought of using the expect command itself, although Expect.pm did come to mind a couple hours after posting my question. I suppose that's the most sensible way of handling this, given that the code to actually do the remote module installs is Expect.pm-based, but I was still hoping to find something more streamlined even after I thought of it. (I'm... less than fond of Expect, as it seems to enforce a style of coding that feels ugly and cumbersome to me. But I can't think of any model that suits my taste better without giving up a lot of the flexibility and power of expect, so I guess I can't complain all that much about it.)
So I guess I'm off to roll this into the existing code. Thanks for the suggestions, everyone!