sub prompt { -t STDIN and print "\n? "; } while ( prompt(), defined($_=) ) { chomp; print "$_\n"; }