I've not written scripts along these lines before, but have you looked into Expect and also the $| variable? I think $| sets the flushing behavior on Perl's output only, but I could be wrong. The Expect module is designed to automate use of this sort of prompt-the-user tool.