in reply to Re^2: Trouble with an array inside a format call
in thread Trouble with an array inside a format call

I certainly can't rule out some kind of OS or installation specific thing that makes your setup different than mine. I am using WinXP and ActiveState 5.10, although I know from experience this is the same on ActiveState 5.6.

Here is a simple test program. Try it on your machine and see if you get the same results.

#!/usr/bin/perl -w use strict; $|=1; #test was run with and without this statement #this turns buffering off print "this is a test\n"; print "this is a test2\n"; print STDERR "this is an error after line2\n"; print "this is a test3\n"; print "this is a test4\n"; __END__ Prints: without $|=1........ this is an error after line2 this is a test this is a test2 this is a test3 this is a test4 Prints: Now with $|=1 ...... this is a test this is a test2 this is an error after line2 this is a test3 this is a test4
The STDERR message gets printed first because the lines from STDOUT haven't gone to the screen yet.

Using $|=1 decreases I/O performance by maybe 30% or something like that. Normally of no consequence unless you are doing a lot of output or are trying to get the time sequence of things right.

Update: deleted few lines about my version of tee.pl as there is a similar topic going on in another thread and I got them confused. Re^3: Getting user input with STDOUT tee to file.

Replies are listed 'Best First'.
Re^4: Trouble with an array inside a format call
by chromatic (Archbishop) on Oct 17, 2009 at 21:10 UTC
    I certainly can't rule out some kind of OS or installation specific thing that makes your setup different than mine.

    I don't know a thing about Windows I/O, but the program behaves the same way (as I expect) on Linux with and without $| = 1;.