I swear, I really do, that I'm really not responsible for what happens the next time someone says "Maybe you're suffering from buffering!" without noticing that the code prints to standard output and includes a newline character.
If you don't understand the problem, please refrain from giving a misleading and unhelpful answer -- you aren't helping the person with the problem and you're spreading misinformation that makes it more difficult to give people the right answers.
It's not difficult to understand. I even wrote Unnecessary Unbuffering to help you understand.
Re:A question then...
chromatic on 2006-08-09T03:26:11
Yep, it's part of the standard header in all of his programs, not just his CGI ones. (If you read more than one of his columns, he copies and pastes that explanation.)
I think it's an unnecessary pessimization in terms of clarity and performance. Most of the time, buffering isn't a problem. Only change the default when it is.
only when necessary
Crag on 2006-08-09T13:42:26
"Most of the time, buffering isn't a problem. Only change the default when it is."This seems like an excellent rule of thumb even for a more general context. Maybe I'll leave "use strict; use warnings;" out of my templates and only put them in code while its tests aren't passing.
(I'm only about 20% serious.)
Re:only when necessary
chromatic on 2006-08-09T17:13:18
Ah, but my default rule of thumb has an implicit "Assuming the default is good and useful..." preface. I can see now that my buffering rule of thumb is one of the 20% of cases where that clause should be explicit.
Re:A question then...
merlyn on 2006-08-12T14:35:46
It's probably partly legacy, partly defensive. In the "old days", if you printed trace messages, you never saw them unless you unbuffered output. And I frequently print trace messages while I'm "debugging" (as I describe in my debugging web apps column).Nowadays, I tend to use only "warn" for trace messages, so perhaps I should change my default style for non-CGI things.
If you don't understand the problem, please refrain from giving a misleading and unhelpful answer
The problem with this advice is that people have to know that the don't understand the problem...
Re:It sounds like your message is not getting out
runrig on 2006-08-10T02:57:59
I hope you checked for STDOUT and a newline before you said that...I fear the consequences otherwise:-)