I'm stuck with getting the STDOUT buffer to flush for a web app i'm writing. here's the issue:

i have a script that instantiates display objects, then prints out the results. let's call it index.cgi

index.cgi basically does this:

my $page = DisplayModule->new(); my $html = $page->build_page; print $page;
not much processing there.

the display module makes some decisions about what page to build, then build them, collecting all of the HTML ( to be later printed by index.cgi )

one of the methods in DisplayModule ( that gets called by the build_page routine ) needs to print some 'status messages' out to the screen before the HTML is rendered. but the print statements live in another module, let's call it Debugger.pm

so in DisplayModule->build_page, an new Debugger is created. something like this:

sub build_page { my $self = shift; #### the usual arg processing, etc my $debug = Debugger->new(); $debug->debug_it(); ### gather up more info, stick it into the $html var return $html; }
but none of these give me the desired behavior -- status messages on STDOUT ( the client browser ) while the html is being gathered by the rest of the program.

is there something i'm overlooking?


In reply to unbuffering I/O with objects by geektron

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.