How can I replace all 'die's with 'confess' in a Perl application?

后端 未结 4 1307
迷失自我
迷失自我 2021-02-02 13:56

I\'m working in a large Perl application and would like to get stack traces every time \'die\' is called. I\'m aware of the Carp module, but I would prefer not to search/replace

4条回答
  •  -上瘾入骨i
    2021-02-02 14:43

    What about setting a __DIE__ signal handler? Something like

    $SIG{__DIE__} = sub { Carp::confess @_ };
    

    at the top of your script? See perlvar %SIG for more information.

提交回复
热议问题