Re: Fetching input character without newline?
- From: "robertospara" <robertospara@xxxxxxxxx>
- Date: 19 Nov 2006 15:57:58 -0800
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 :
or change regex/^([1-5])/ or /^([1-5])\n$/.chomp $ret;<<<<<<<<<<<<<<<<<<<<
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
.
- Follow-Ups:
- Re: Fetching input character without newline?
- From: Mark
- Re: Fetching input character without newline?
- From: Tad McClellan
- Re: Fetching input character without newline?
- References:
- Fetching input character without newline?
- From: Mark
- Fetching input character without newline?
- Prev by Date: Re: Fetching input character without newline?
- Next by Date: Re: context sensitive grammar?
- Previous by thread: Re: Fetching input character without newline?
- Next by thread: Re: Fetching input character without newline?
- Index(es):
Relevant Pages
|