hi, maybe u should redefined the __DIE__ handle for the reason of safety. such as:
$SIG{__DIE__}=\&log_die; sub log_die { open (HDW,">>",$err_log); select HDW;$|=1;select STDOUT; print HDW @_; close HDW; die @_; } 2005/10/8, Timothy Johnson <[EMAIL PROTECTED]>: > It partly depends on your operating system, I think. That's fine on > Windows, but on UNIX I think that under some if not all circumstances > your change will persist after the script finishes executing. I've > never had to do it, but I've seen one method that goes like this: > > open(OLD_STDERR,">&STDERR") or die "Failed to save STDERR"; > open(STDERR,">script.err") or die "Failed to redirect STDERR"; > > do something... > > open(STDERR,">&OLD_STDERR") or die "Failed to restore STDERR"; > > > -----Original Message----- > From: Ryan Frantz [mailto:[EMAIL PROTECTED] > Sent: Friday, October 07, 2005 12:10 PM > To: beginners@perl.org > Subject: Redirecting STDERR > > Perlers, > > I have a script where I redirect STDERR to a file so that I can capture > 'die' messages like so: > > use warnings; > use strict; > > my $logfile = "/some/path/logfile.txt"; > > open STDERR, ">>$logfile"; > > something or die "Unable to do something()\n"; > > close STDERR; > > Is it kosher to do this? Or is there a more preferred method to > redirect 'die' messages? > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > <http://learn.perl.org/> <http://learn.perl.org/first-response> > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>