Why should that be the case? I read on the linked page that print() calls on terminal is line buffered, so why there is buffering asks for another reason. Or is this phanomenon platform-dependent?
If you run this, you find that it works the way you expect: The prompt appears on the screen right away. Where's the buffering? Why didn't Perl save up the output until it had a full buffer? Because that's almost never what you want when you're writing to a terminal, the standard I/O library that Perl uses takes care of it for you. When a filehandle is attached to the terminal, as STDOUT is here, it is in line buffered mode by default. A filehandle in line buffered mode has two special properties: It's flushed automatically whenever you print a newline character to it, and it's flushed automatically whenever you read from the terminal. The second property is at work here: STDOUT is flushed automatically when we read from STDIN.
Short test:
% perl print "Hi. Your name, please: "; chomp( my $name = <STDIN> ); print "Oh, $name, I think I am your system. Glad to be at your service +.\n"; # Press CTRL-D or whatever shortcut to trigger EOF Hi. Your name, please: Florian Oh, Florian, I think I am your system. Glad to be at your service.
In reply to Re^2: The text preceding <STDIN> is not printed
by flowdy
in thread The text preceding <STDIN> is not printed
by c_config
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |