Why are use warnings; use strict; not default in Perl?

前端 未结 6 1654
北海茫月
北海茫月 2020-12-03 10:00

I\'m wondering why

use warnings;
use strict;

are not default in Perl. They\'re needed for every script. If someone (for good reason) need

6条回答
  •  既然无缘
    2020-12-03 10:31

    Well, use strict is default now, sort of.

    Since Perl 5.12.0 if you require a version of Perl >= 5.12.0, then your script will have all the backwards incompatible features turned on, including strict by default.

    use 5.12.0;
    use warnings;
    

    Is the same as:

    use strict;
    use warnings;
    use feature ':5.12';
    

    It hasn't been turned on more broadly because doing so would break a lot scripts that people depend on to "just work".

    Moose also automatically turns on strict and warnings when you use it. So if you do any Moose based Perl OOP, then you get a free pass here, too.

提交回复
热议问题