In my script I have a place where I run chunks of code and being that I am a lazy programmer I would like to capture STDOUT and combine it with any data I decide to return.
sub foo {
my $captured_printed_data;
my $SH = tie *STDOUT, 'IO::Scalar', \$captured_printed_data;
$return_data = eval $module_code;
$return_data = "$captured_printed_data \n$return_data" if(defined($c
+aptured_printed_data) || ($captured_printed_data ne ''));
close $SH;
untie *STDOUT;
return $return_data;
}
When I run this using Komodo or command line it works just fine but when I run the script in Apache it doesn't display anything. Like the STDOUT is still tied. I am running Apache 1.3.x on Linux.
-- BigJoeLearn patience, you must. Young PerlMonk, craves Not these things. Use the source Luke.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|