Re: Fetching input character without newline?



Mark <anon40629@xxxxxxxxxxx> wrote in comp.lang.perl.misc:
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?

perldoc -q 'single character'

Anno
.



Relevant Pages

  • 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)
  • Re: Fetching input character without newline?
    ... Crazy people, crazy world:) ... 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)