NAME

Tie::STDERR - Send output of your STDERR to a process or mail

SYNOPSIS

use Tie::STDERR;
if (;

use Tie::STDERR 'root';

use Tie::STDERR 'root', 'Errors in the script';

use Tie::STDERR '>> /tmp/log';

use Tie::STDERR '| mail -s Error root';

DESCRIPTION

Sends all output that would otherwise go to STDERR either by email to root or whoever is responsible, or to a file or a process. This way you can easily change the destination of your error messages from inside of your script. The mail will be sent or the command run only if there actually is some output detected -- something like cron would do.

The behaviour of the module is directed via the arguments to use, as shown above. You can optionally give the name of the recipient and the subject of the email. Argument that starts with | will send the output to a process. If it starts with > or >>, it will be written (appended) to a file. If the argument is explicit undef, if will untie previous tieness.

The module will catch all output, including your explicit prints to STDERR, warnings about undefined values, dies and even dies as a result of compilation error. You do not need any special treatment/functions -- Tie::STDERR will catch all.

My main goal was to provide a tool that could be used easily, especially (but not only) for CGI scripts. My assumption is that the CGI scripts should run without anything being sent to STDERR (and error_log, where it mixes up with other messages, even if you use CGI::Carp). We've found it usefull to get delivered the error and warning messages together with any relevant information (%ENV) via email.

Under mod_perl, Tie::STDERR sends the message the same way it would with normal scripts.

BUGS

The Tie::STDERR catches the compile time errors, but it doesn't get the reason, only the fact that there was an error. I do not know how to fix this.

VERSION

0.20

AUTHOR

(c) 1998 Jan Pazdziora, adelton@fi.muni.cz, http://www.fi.muni.cz/~adelton/ at Faculty of Informatics, Masaryk University in Brno, Czech Republic