perl, Open and close STDOUT

Posted on 2011-04-20
Last Modified: 2012-05-11
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.

Question by:rgbcof
    LVL 8

    Expert Comment

    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


    Author Comment

    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?
    LVL 8

    Accepted Solution

    What error do you get when you try the last line to open STDOUT again?

    Author Closing Comment

    Your last line did work.  Thank you.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Suggested Solutions

    I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
    There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now