in reply to Testing a subroutine with STDIN

I believe IO::Prompt could be what you need.