sub readprompt { my $prompt = shift; print $prompt if -t STDIN; <>; } while (my $i=readprompt(">>")) { print "You said: $i\n"; }