Re: Fetching input character without newline?
- From: "robertospara" <robertospara@xxxxxxxxx>
- Date: 19 Nov 2006 18:22:25 -0800
My compiler is showing that construction >>>>>>>>>while() <<<<<<<<
it's a syntax error. And I agree with it value in the brackets is
undefined, so what can we do
with it. Not proper usage of while loop. That what I
think!!!!!!!!!!!!!!
On 20 Lis, 03:18, "robertospara" <robertosp...@xxxxxxxxx> wrote:
U are crazy with your ideas :)>>>>I already tried that one, and it didn't work.What U have tried ?????????????????????????????
#!/usr/bin/perl -w
use strict;
print "Enter your response here (1-5): ";
while(<STDIN>){
if (/^([1-5])$/){
print "\nUser chose $1\n";
last;
};
print "Try again (1-5): ";
}On 20 Lis, 02:58, "Mark" <anon40...@xxxxxxxxxxx> wrote:
"robertospara" <robertosp...@xxxxxxxxx> wrote:
First of all read quick reference to regular expressions in perl.as soon as I press <enter> and THEN $ret gets the data from STDIN.
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$/.I already tried that one, and it didn't work. The screen output wrapschomp $ret;<<<<<<<<<<<<<<<<<<<<
So it's too late to try to undo the carriage return as far as STDOUT is
concerned.
This is why I was hoping for a "magic" input record terminator. . .
one that would cause the assignment from STDIN to complete
without causing the screen output to wrap.
.
- References:
- Fetching input character without newline?
- From: Mark
- Re: Fetching input character without newline?
- From: robertospara
- Re: Fetching input character without newline?
- From: Mark
- Re: Fetching input character without newline?
- From: robertospara
- Fetching input character without newline?
- Prev by Date: Re: Perl is worth nothing!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- Next by Date: Re: Fetching input character without newline?
- Previous by thread: Re: Fetching input character without newline?
- Next by thread: Re: Fetching input character without newline?
- Index(es):
Relevant Pages
|