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.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.