Fetching input character without newline?



Good afternoon.

I am attempting to solicit user input using the following:

while ()
{
print "Enter your response here (1-5): ";
$ret = <STDIN>;
if ($ret =~ /^([1-5])$/)
{print "\nUser chose $1\n";
last;
}
}

This code reprints the prompt string on the next line each time
the user responds incorrectly. I would _like_ to handle an incorrect
response by erasing the user's entry and leaving the prompt in place
on the current line.

Any suggestions on how to do this?

Thanks
-Mark


.



Relevant Pages

  • Re: Fetching input character without newline?
    ... I am attempting to solicit user input using the following: ... This code reprints the prompt string on the next line each time ... I would _like_ to handle an incorrect ...
    (comp.lang.perl.misc)
  • incorrect function?
    ... i realised there are a few episodes i cant play ... using windows media player.. ... it appears a prompt "Incorrect function".. ...
    (microsoft.public.windowsmedia.player)
  • Re: An MT vent
    ... (sometimes Word will prompt with the correct spelling of an incorrect ... Do you know, Bambi? ...
    (sci.med.transcription)
  • Re: su issues
    ... >even prompt me to type a password and automatically jumps to reporting ... >it as incorrect). ... Or simply do this on the prompt: ...
    (linux.redhat)
  • Re: Cant get onto computer - please help!
    ... 'Ctrl+Alt+Del' it said that the task manager had been 'disabled by my ... administrator' so how do I sort that out? ... > a prompt. ... > parameter is incorrect. ...
    (microsoft.public.win2000.general)