Under mod_perl, both STDIN and STDOUT are tied to the socket from which the request originated. If, for example, you use a third-party module that prints some output to STDOUT when it shouldn't (for example, control messages) and you want to avoid this, you must temporarily redirect STDOUT to /dev/null. You will then have to restore STDOUT to the original handle when you want to send a response to the client. The following code demonstrates a possible implementation of this workaround:
{
my $nullfh = Apache::gensym( );
open $nullfh, '>/dev/null' or die "Can't open /dev/null: $!";
local *STDOUT = $nullfh;
call_something_thats_way_too_verbose( );
close $nullfh;
}
The code defines a block in which the STDOUT stream is localized to print to /dev/null. When control passes out of this block, STDOUT gets restored to the previous value.
STDERR is tied to a file defined by the ErrorLog directive. When native syslog support is enabled, the STDERRstream will be redirected to /dev/null.
 
Continue to: