in reply to Re: Signals and die message
in thread Signals and die message

anyway to avoid seeing the message statement get outputed twice?

Replies are listed 'Best First'.
Re^3: Signals and die message
by Roy Johnson (Monsignor) on Feb 24, 2005 at 17:08 UTC
    Exit during the signal handler:
    $SIG{__DIE__} = sub { my $msg = shift; # This calls the real die die "What I really want to see"; }; die "Hide me!\n";

    Caution: Contents may have been coded under pressure.
Re^3: Signals and die message
by mifflin (Curate) on Feb 24, 2005 at 17:44 UTC
    If you are seeing it twice you are probably printing the error message in your handler. If you don't wrap your die in an eval you will see the message twice...
    erickn@isfe:/home/erickn> cat y $SIG{__DIE__} = sub { print $_[0] }; die "hi"; erickn@isfe:/home/erickn> perl y hi at y line 4. hi at y line 4.
    Wrapping in an eval will stop it...
    erickn@isfe:/home/erickn> cat x $SIG{__DIE__} = sub { print $_[0] }; eval { die "hi"; }; erickn@isfe:/home/erickn> perl x hi at x line 5.