[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 682
  • Last Modified:

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.

Help.
0
rgbcof
Asked:
rgbcof
  • 2
  • 2
1 Solution
 
DocSeltsamCommented:
Hi there,

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

Open in new window


use IO::Handle;
STDOUT->autoflush(1);

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


--TheDoctor
0
 
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?
0
 
DocSeltsamCommented:
What error do you get when you try the last line to open STDOUT again?
0
 
rgbcofAuthor Commented:
Your last line did work.  Thank you.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now