On Jul 17, 9:24 pm, [EMAIL PROTECTED] (Yitzle) wrote: > 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...
Hi yitzle Thank you for your kind help. I think timestamp is a good idea. Actually, the code is used for logging. And I will change STDERR output to STDOUT output, adding timestamp and some flags to identify error lines. Thank you. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/