in reply to Signals and die message

Try this:
$SIG{__DIE__} = sub { # your handler here, message in $_[0] }

Replies are listed 'Best First'.
Re^2: Signals and die message
by Roy Johnson (Monsignor) on Feb 24, 2005 at 15:48 UTC
    And note that the error message you gave die() is passed in as the first argument to the sub. (see perldoc perlvar)

    Caution: Contents may have been coded under pressure.
Re^2: Signals and die message
by EchoAngel (Pilgrim) on Feb 24, 2005 at 16:26 UTC
    anyway to avoid seeing the message statement get outputed twice?
      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.
      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.