I want to follow the execution of my program but $|=1 seems to be not doing its job. It only shows the results when it finish to process. Could any help me. Here is the code I'm using.
#!/usr/bin/perl -wT BEGIN { $|=1; print "Content-type: text/html\n\n"; use CGI::Carp('fatalsToBrowser'); } use DBI; use CGI; $query = new CGI; $month = $query->param('m'); $year = $query->param('y'); $table_name = $month."_".$year; printf "Connecting to the database ............<br>\n"; ($dbhost, $dbname) = qw/xx.xxxxxxx.com.xx xxxxxxxxx/; ($user, $pass) = qw/xxxxxxxx xxxxxx /; $dbh = DBI->connect("DBI:mysql:hostname=$dbhost:database=$dbname", $us +er, $pass); printf "Creating temp table if not exist ............<br>\n"; $sql = "CREATE TABLE IF NOT EXISTS tmp_table (ClientIP Char(20),Qty IN +T)"; if (!$dbh->do($sql)) { printf "Error creating tmp_table table: " . $DBI::errstr; $dbh->disconnect; exit; } printf "Select from $table_name ............<br>\n"; $sql = "SELECT ClientIP, count(ClientIP) as Qty FROM " . $table_na +me; $sql .= " GROUP BY ClientIP"; $res = $dbh->prepare($sql); if ($res->execute) { while($data = $res->fetchrow_hashref) { $hits = int($data->{Qty}); if ($hits > 100) { printf "Insert " . $data->{ClientIP} . " - " . $data->{Qty} . " ...... +......<br>\n"; $sql = "INSERT INTO tmp_table (ClientIP,Qty) values (" +; $sql .= "'" . $data->{ClientIP} . "',"; $sql .= "'" . $data->{Qty} . "')"; if (!$dbh->do($sql) ) { printf "Error adding tmp_table table: $DBI::errstr +"; } } } } else { printf "Error selecting from " . $table_name ." table: $DBI:: +errstr\n"; } $res->finish; printf "that's all for now Folks!!<br>\n";

Edit by tye: title, READMORE


In reply to flushing CGI output by Anonymous Monk

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.