perl, Open and close STDOUT

I am using perl for my cgi program.
I am using "$| = 1;" to autoflush.
However, autoflush is not working properly because of the web server I am using, so I had to close STDOUT force the outpout.

Now, I would like to reopen, reenable, or anything that would get STDOUT to work again.  
Note:  "open STDOUT" "open (STDOUT)" does not work.

Who is Participating?
DocSeltsamConnect With a Mentor Commented:
What error do you get when you try the last line to open STDOUT again?
Hi there,

first thing, have you these?
select STDOUT; $| = 1;  # make unbuffered

Open in new window

use IO::Handle;

Open in new window

To reopen STDOUT you have to the followinf I think

open STDOUT, '>-' or die "Can't open STDOUT: $!";

Open in new window

rgbcofAuthor Commented:
I forced the Web Server to autoflush with the command you gave above.  But it does not work because there is something wrong with webserver.  If i close STDOUT, then it will flush, but the problem is I can not reopen STDOUT again.  Help.  How do you re-open STDOUT after closing?
rgbcofAuthor Commented:
Your last line did work.  Thank you.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.