my $prompt = q{Enter name ( to exit) : }; my $dePrompt = qq{\r} . q{ } x (length($prompt) + 2) . qq{\r}; while (1) { print $prompt; last if eof STDIN; chomp(my $response = ); # Do something with $response here ... } print $dePrompt;