Works fine for me, until I add the browser to the equation.

The program I used:

#!/usr/bin/perl $| = 1; print <<'END_HTML'; Content-type: text/html <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <head> <title>PAGE TITLE</title> </head> <body> <p>Start. END_HTML sleep(5); print <<'END_HTML'; <p>done. </BODY> </HTML> END_HTML

Running it from the prompt:

$ foo.cgi Content-type: text/html <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <head> <title>PAGE TITLE</title> </head> <body> <p>Start. ...waits 5 secs... <p>done. </BODY> </HTML>

Running it from via the web server:

$ telnet www.example.com 80 Trying 11.22.33.44... Connected to www.example.com. Escape character is '^]'. GET /script.cgi HTTP/1.0 Host: www.example.com HTTP/1.1 200 OK Date: Mon, 17 Dec 2007 22:39:09 GMT Server: Apache/2.0.54 (Unix) PHP/4.4.7 mod_ssl/2.0.54 OpenSSL/0.9.7e m +od_fastcgi/2.4.2 DAV/2 SVN/1.4.2 Vary: Accept-Encoding Connection: close Content-Type: text/html <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <head> <title>PAGE TITLE</title> </head> <body> <p>Start. ...waits 5 secs... <p>done. </BODY> </HTML> Connection closed by foreign host.

But when viewed in FireFox 2, it waits for the entire document to arrive before display it.


In reply to Re: I think I'm misunderstanding $| by ikegami
in thread I think I'm misunderstanding $| by sigmazero13

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.