mwhuen
asked on
$|
can you explain what is the use of :
$| = 1;
in perl cgi program?
if I don't use it, any problem will happen?
$| = 1;
in perl cgi program?
if I don't use it, any problem will happen?
ASKER
In my perl cgi program, I want to create a html and write to it, as the same time, i want to display it on the web, can i use $|=1 to accomplish my job?
ASKER
Adjusted points to 20
Yes.
Note that browsers might not support 'streaming' HTML and they may also treat it differently. One might not start parsing the page at all before the entire page is downloaded. Others wil parse everytime a \n is encountered while others wait for <BR> og <P> etc... Netscape up to v. 4.7 does not render tables untill the entire table is downloaded while IE seems to attempt this.
Note that browsers might not support 'streaming' HTML and they may also treat it differently. One might not start parsing the page at all before the entire page is downloaded. Others wil parse everytime a \n is encountered while others wait for <BR> og <P> etc... Netscape up to v. 4.7 does not render tables untill the entire table is downloaded while IE seems to attempt this.
ASKER
I can't make it.
My code is :
$|=1;
....
print "content-type:text/html\n\ n";
....
....
open(NEWHTML,">new.html");
print NEWHTML<<XXX;
....
....
XXX
close(NEWHTML);
I expect the new.html is displayed on the screen by this CGI program.
But, It doesn't display, though new.html is created.
My code is :
$|=1;
....
print "content-type:text/html\n\
....
....
open(NEWHTML,">new.html");
print NEWHTML<<XXX;
....
....
XXX
close(NEWHTML);
I expect the new.html is displayed on the screen by this CGI program.
But, It doesn't display, though new.html is created.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
autoflush HANDLE EXPR
$OUTPUT_AUTOFLUSH
$| If set to nonzero, forces a flush right away and
after every write or print on the currently
selected output channel. Default is 0 (regardless
of whether the channel is actually buffered by the
system or not; $| tells you only whether you've
asked Perl explicitly to flush after each write).
Note that STDOUT will typically be line buffered
if output is to the terminal and block buffered
otherwise. Setting this variable is useful
primarily when you are outputting to a pipe, such
as when you are running a Perl script under rsh
and want to see the output as it's happening.
This has no effect on input buffering. (Mnemonic:
when you want your pipes to be piping hot.)