Tom Phoenix schrieb:
> On 10/18/06, Chris Share <[EMAIL PROTECTED]> wrote:
> 
>> I've got a question about $| = 1;
> 
> ....
> 
>> If I add $| = 1; at the top of the program this fixes the problem and
>> the program runs as expected.
> 
> 
> Normally, output is buffered for efficiency; instead of writing each
> byte at once, output is saved in a buffer. The buffer is automatically
> flushed under various circumstances, such as end-of-program, or when
> the buffer gets full. Setting $| to 1 flushes the buffer after each
> print or printf statement, as you found, so it's much like having no
> buffer at all.
> 
> Usually the buffer is flushed whenever the program stops to read
> input; your system seems to be an exception. Perhaps your perl binary
> is misconfigured? Or maybe you have a non-Unix system that does I/O
> differently than most. But what you describe isn't quite the
> documented behavior.
> 

It's not the documented behavior when running from the CLI, but the OP
wrote:

Chris Share:
> Hi,
>
> I'm a C programmer teaching myself Perl. I'm working on Windows XP using
> ActivePerl and Eclipse (EPIC).

I've seen this with so many Editors (no, better: IDE's), it's definitely
not a Perl issue, but, in this case, a Eclipse issue. I havn't dug too
far into this, but each IDE (that I know  of) that offers to run perl
inside its own Console suffers from this problem: there seems to be
another layer of buffering going on (Eclipse calls this: 'Allocate
Console') that makes it necessary to autoflush.

So, to the OP, if  you want to take input from your program when run
inside Eclipse, you will need to fiddle with $|, due to that
extra-buffering-layer. If you run it outside Eclipse, there shouldn't be
a need to do so.

Kind greetings,

Andreas Puerzer

-- 
perl -mAcme::JAPH

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to