in reply to
Re: Never, never, never
in thread Never, never, never
"Never disable buffering without a good reason", eh?
I'm actually of the opposite opinion, and I turn it off out of habit. I think this is a case where the default is wrong:
turning buffering on should be regarded as a performance hack.
The trouble is that a lot of beginning perl scripts are
mixtures of back-ticks and perl output -- an early use for me was an attempt at adding some readable column descriptions to the output of a unix command-line utility. What happens with buffering turned on is that you get the output from these two sources intermixed in an almost random fashion. And the reason this is happening is not at all obvious, in fact I would argue it's nearly impossible to figure out -- even if it occurs to you to read the docs for the special variables, there's nothing about the writeup for "$|" that would leap out at you (do I want my "pipes to be piping hot?").
So this is a hard one... if the default were different, perl might have an undeserved reputation for slow output, but as it is there's a nasty little gotcha in there. I tend to shut off $| for all my command line scripts... though of course you probably *shouldn't* do that in something like a CGI script.