|Think about Loose Coupling|
Autoflush and web browsers (was: Clever autoflush detail)by talexb (Canon)
|on Jun 20, 2007 at 17:49 UTC||Need Help??|
talexb has asked for the wisdom of the Perl Monks concerning the following question:
I received a query from a client about how to get autoflush working, so cobbled together a simple example. First, I did it in shell,
This worked fine (it output a line every second), and I translated it into Perl.
This didn't work. Nothing was output until the script finished. I was stumped. I search Perlmonks and found lots of information on autoflush questions, nodes Autoflush $|?, Autoflushing Laser printer, How to get explicity the autoflush var ($|) of a TIED HANDLER?, Autoflushing revisited., Simple autoflush module, OUTPUT_AUTOFLUSH, autoflush and 'DESTROY', autoflushing.. and When to use Autoflush. Nothing solved my problem.
Finally, over on IRC, I put my question and got a response from Caelum -- use PRE tags.
Well, to cut a long story short, it works. But why?
Shouldn't the autoflushing (happening down at layer 2 or 3) be immune to the presentation (up at layer 7)? Is this a Perl oddity?
What is going on?
Update: As fenLisesi points out, the closing pre tag in the 'Value is' print statement shouldn't be there, but I won't edit the original node to reflect that..
Update 2: I don't mind changing the title of this node to Autoflush and web browsers, but that's naming the thread after the fact -- after we know (or suspect) that it's the interaction with the browser that's causing the odd behaviour. In addition, it looks like most of the discussion on this thread is over (at the time of writing, the most recent reply to the root was shmem's dated 18 hours ago), so this consideration may not be necessary.
Update 3: Brother benizi makes a very good point -- retitling the node would be an aid to future searches, therefore it's a Good Thing. I've held off voting on the consideration or making a title change, but now I'm convinced.