Re: Fetching input character without newline?



First of all read quick reference to regular expressions in perl.
Secound U take '\n' - newline character
with <STDIN> and in /^([1-5])$/ U don't want it. So or :
chomp $ret;<<<<<<<<<<<<<<<<<<<<
or change regex/^([1-5])/ or /^([1-5])\n$/.
Crazy people, crazy world:)
Mark napisal(a):
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