On Wed, Jul 16, 2008 at 9:01 PM,  <[EMAIL PROTECTED]> wrote:
> Hi experts
> When I am using STDERR and STDOUT for mixed output, I found a problem.
> Output of STDERR and STDOUT can not be mixed.
> Here is the snippet.
>
> #####################################
> print STDOUT "This is STDOUT\n";
> print STDERR "This is STDERR\n";
> print STDOUT "This is STDOUT\n";
> #####################################
>
> I thought the result shoud be
> --------------------------------------
> This is STDOUT
> This is STDERR
> This is STDOUT
> --------------------------------------
>
> but the actual result is
> --------------------------------------
> This is STDERR
> This is STDOUT
> This is STDOUT
> --------------------------------------
>
> Then I set $| = 1;
> the result became
> --------------------------------------
> This is STDERR
> This is STDOUT
> This is STDOUT
> --------------------------------------
>
> I also tried set autoflush
> STDOUT->autoflush(1);
> STDERR->autoflush(1);
>
> But I can not get the result as I expected.
> Anyone know what's up?
>
> Thank you.

Other than the fact that it works fine for me, STDERR and STDOUT are
two separate streams. They can experience delays between being written
to and having the message appear on the terminal, assuming that is
where you are viewing the two. I don't think there is any guaranty of
order between the two. You can pipe the two streams to two separate
files or timestamp the output...

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


Reply via email to