First I want to say I solved the problem with help from posts from tilly & maverick. Kudos to my fellow mongers for saving my butt again! However, I don't know why my original approach was failing so now I'm asking you. I needed to capture STDOUT in a web application. I was using IO::Scalar to do it via this code:
my $content; tie *STDOUT, 'IO::Scalar', \$content; do $file; untie *STDOUT; return $content;

What was happening is that I got the proper data back from the called code, but I couldn't print to STDOUT! If I printed $content to STDERR the error log showed the proper putput. It seems obvious to me now that STDOUT was somehow either getting closed or was not getting untied. Now I'm using

tie(*CAPTURE, 'IO::Scalar', \$content); select(CAPTURE); $| = 1; do $file; select(STDOUT); untie(*CAPTURE); return $content;
and it works 100% as expected. But I don't understand why the old approach did not work. This is a web app and the browser got nothing but some empty headers I believe Apache or CGI.pm was adding. Any thoughts?

In reply to Capturing STDOUT by drewbie

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.