Rob Dixon wrote:

> Sudarshan Raghavan wrote:
> >
> > Both STDERR and STDOUT are line buffered, when a "\n" is seen
> > the contents of the buffer is flushed. Turning on autoflush is superfluous
> > in this case. Try this instead :-)
> >
> > #!/usr/local/bin/perl
> > use strict;
> > use warnings;
> >
> > select (STDERR);
> > $| = 1;
> > print STDOUT "STDOUT";
> > print STDERR "STDERR";
>
> As I pointed out, precisely how the streams are handled is
> platform-dependent. On my Win2KPro system this
>
>     print STDERR "STDERR\n";
>     print STDOUT "STDOUT\n";
>
> outputs this
>
>     STDOUT
>     STDERR
>
> so they are clearly not line-buffered. Whether it is generally
> true that they are on *nix systems I cannot say.
>
> Cheers,
>
> Rob

Hi Rob,

I think you have it reversed.  Had me going for awhile, too.  If you retest, you may 
see what I mean.  Think about it a little--when you run a program, do you expect 
everything to run, and then report your errors?  Vicee-versetz, nay?  So far this only 
works for me on the 5.8 installation, but:

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

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

One possible difference--on the box running 5.61, I have only two other application 
windows open, and the script is the only open window in PFE.  The PC running 5.8 has 
19 applications open, including two browsers, each with long session histories, and 
eleven files open in PFE.  It could be that without autoflush explicitly called, the 
system flushes at low-priority opportunity.

Anyway, this is my take on the question:

1)  When there is a difference, STDERR would take precedence, since it is more 
critical to report operating errors than to return [possibly erroneous] output.

2) The inversion behavior you describe without autoflush can not be repeated 
dependably across systems.

3) The sequence of output will dependably track the sequence of input with autoflush 
turned on.

Joseph



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

Reply via email to