Link to home
Start Free TrialLog in
Avatar of mwhuen
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?
Avatar of ozo
ozo
Flag of United States of America image

perldoc perlvar
                 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.)
Avatar of mwhuen
mwhuen

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?
Avatar of mwhuen

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.
Avatar of mwhuen

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.

ASKER CERTIFIED SOLUTION
Avatar of furu
furu
Flag of Norway image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial