>
>Hi,
>       How do I redirect the warning messages from my perl script to a
>different file? By default they are all getting printed on the terminal.

Hello,

You can redirect all 'die' or 'warn' messages to files via re-defining the 
SIGDIE and SIGWARN handler.

Like:

$SIG{__DIE__} = \&log_die;
$SIG{__WARN__} = \&log_warn;

sub log_die
{
    write_log(@_);
    die @_;
}

sub log_warn
{
    write_log(@_);
}

sub write_log
{
     open LOG,">>",$logfile;
     print LOG @_,"\n";
     close LOG;
}

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to