in reply to Re^2: Trouble with an array inside a format call
in thread Trouble with an array inside a format call
Here is a simple test program. Try it on your machine and see if you get the same results.
The STDERR message gets printed first because the lines from STDOUT haven't gone to the screen yet.#!/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
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 |