Re: Fetching input character without newline?



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.
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$/.I already tried that one, and it didn't work. The screen output wraps
as soon as I press <enter> and THEN $ret gets the data from STDIN.
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.

.



Relevant Pages

  • Re: syntax errors
    ... As Harvey indicates you have typed the second set of brackets from the ... You must either insert the Numpages field or use CTRL+F9 for the ... Word MVP web site http://word.mvps.org ... Word help tells which formula to use, but I get a syntax error every ...
    (microsoft.public.word.docmanagement)
  • RE: How do I use the INSERT INTO Statement in VBA?
    ... When the fields name contain two seperate names you need to put then in ... > Syntax error in INSERT INTO Statement. ... Prev by Date: ...
    (microsoft.public.access.modulesdaovba)
  • Re: ON ... AND statement problem
    ... long experience with SQL. ... it works with enough brackets. ... Finally because my different tests with WHERE gave me "syntax error" and ... clause I would try something else but would you be so kind to explain why, ...
    (microsoft.public.access.queries)
  • Re: Simple delphi IF statement.
    ... that's a syntax error. ... The brackets around each test are necessary because the compiler has to ... be able to resolve equations to "true" or "false" before it can decide what ... nicer --and easier-- to do it the other way. ...
    (comp.lang.pascal.delphi.misc)