How can I make Perl die if a warning is generated?

后端 未结 2 640
我寻月下人不归
我寻月下人不归 2021-02-19 21:30

I would like my script perl to die whenever a warning is generated, including warnings which are generated by used packages.

For example, this should die:



        
2条回答
  •  深忆病人
    2021-02-19 22:06

    I believe you're looking for $SIG{__WARN__} as documented in perlvar. Something similar to

    $SIG{__WARN__} = sub { die @_ };
    

    might be what you want.

提交回复
热议问题