R. Joseph Newton <[EMAIL PROTECTED]> wrote:
> Rob Dixon wrote:
>> Sudarshan Raghavan wrote:
>> >
>> > Both STDERR and STDOUT are line buffered, [...]

Almost!  

The general rule is: stderr is unbuffered and stdout is 
either line buffered (if it points at a terminal) or fully 
buffered if it points at anything else.

>> As I pointed out, precisely how the streams are handled is
>> platform-dependent. [...]

It's possible that your C library behaves unconventionally 
here... but I don't that's what's going on.  msvcrt and glibc
both do the usual thing.

> 
> On 5.8:
> 
> #!/usr/bin/perl
> 
> use strict;
> 
> print STDOUT "STDOUT";
> print STDERR "STDERR";
> print "\n";
> $| = 1;
> print STDOUT "STDOUT";
> print STDERR "STDERR";
> 
>  Yields:
> Hi There,podner E:\d_drive\perlStuff>flush.pl
> STDERRSTDOUT
> STDOUTSTDERR

Right -- this is the line buffering Sudarshan mentioned.

Running this in cmd.exe with with autoflush off, anything
you print to STDOUT will have to wait in a stdio buffer
until you print a newline -- at which point the buffer gets
flushed and everything pops up on the console.

But since stderr is *not* buffered, anything printed to 
STDERR appears on the console immediately, which means the
first line of output is "reversed"

  STDERRSTDOUT

Just as we expect.

> But on Perl 5.61, the same code yields:
> STDOUTSTDERR
> STDOUTSTDERR

But this!  This should never happen...

If you tested 5.6.1 inside an IDE, you might want to run it
again from the command line.

-- 
Steve

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to