perl – 在使用严格时是否有必要使用警告?

前端之家收集整理的这篇文章主要介绍了perl – 在使用严格时是否有必要使用警告?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
代码如下:
use strict;
use warnings;

是使用警告;在这需要吗?

解决方法

是的,这是必要的.

使用严格和使用警告做不同的事情.

从严格模块的手册页:

strict − Perl pragma to restrict unsafe constructs

来自perlrun(for -w):

prints warnings about dubIoUs constructs,such as variable names that are mentioned only once and scalar variables that are used before being set,redefined subroutines,references to undefined filehandles or filehandles opened read-only that you are attempting to write on,values used as a number that don’t look like numbers,using an array as though it were a scalar,if your subroutines recurse more than 100 deep,and innumerable other things.

猜你在找的Perl相关文章