in reply to Problem with STDIN

Thank you perlplexer. Using $|++ allows the prompt to display normally. However, if the prompt and the input are on the same line, the program takes the entire line (prompt and input) as the input. As cromatic said, the obvious solution is to include a newline at the end of each prompt. That is one solution to the problem, but I was wondering if STDIN can be used to get input from a line while not taking in the prompt as well. Again, I don't know much about the nuts and bolts of Perl yet, and my only other programming experience is some very limited knowledge of C++. Anyway, thank you both for your help. If there is a way to read input from a prompt on the same line, please let me know. Otherwise, thank you again for your assistance.

Replies are listed 'Best First'.
Re: Re: Problem with STDIN
by bobn (Chaplain) on Jun 11, 2003 at 23:33 UTC
    It is almost certainly not reading the prompt back in. It may look like it is, as an artifact of end-of-line processing. Modify the print statement to look like this and see what you get:

    print "\nYou entered \n|$number|\n";
    See what's between the two '|' symbols, I'll bet it doesn't include the prompt. Or try chomp $number; before the print.

    --Bob Niederman, http://bob-n.com
      bobn, I tried your suggestion, but it didn't fix the problem. However, Thelonius has said that this is a problem with the Open Perl IDE that I used, not Perl itself or my Windows system's port of it. And when I used a freeware Perl frontend for Win32 systems, the problem did not occur.