Chas. Owens wrote:
On Jan 17, 2008 9:54 AM, Jonathan Mast <[EMAIL PROTECTED]> wrote:
I want to write the errors caught by a 'die' clause into a file.
snip
Try
#!/usr/bin/perl
use strict;
use warnings;
$SIG{__DIE__} = sub {
open my $fh, ">>", "something.log"
or die @_, "could not open something.log: $!";
print $fh @_;
};
die "Oops";
Would this not be susceptible to infinite recursion if it fails to open
something.log? Would it not be safer/better to do something like this
(untested)?
#!/usr/bin/perl
use strict;
use warnings;
sub myDie {
open my $fh, ">>", "something.log"
or die @_, "Could not open something.log: $!";
print $fh @_;
exit 1;
}
myDie "Oops";
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/