Should I use common::sense or just stick with `use strict` and `use warnings`?

后端 未结 9 999
自闭症患者
自闭症患者 2021-01-08 00:37

I recently installed a module from CPAN and noticed one of its dependencies was common::sense, a module that offers to enable all the warnings you want, and none that you do

9条回答
  •  臣服心动
    2021-01-08 01:00

    There is one bit nobody else seems to have picked up on, and that's FATAL in the warnings list.

    So as of 2.0, use common::sense is more akin to:

    use strict; 
    use warnings FATAL => 'all'; # but with the specific list of fatals instead of 'all' that is 
    

    This is a somewhat important and frequently overlooked feature of warnings that ramps the strictness a whole degree higher. Instead of undef string interpolation, or infinite recursion just warning you and then keeping on going despite the problem, it actually halts.

    To me this is helpful, because in many cases, undef string interpolation leads to further more dangerous errors, which may go silently unnoticed, and failing and bailing is a good thing.

提交回复
热议问题