【发布时间】:2017-04-26 20:58:50
【问题描述】:
是否可以在 perl 中基于 ARGV 启用/禁用使用严格 / 警告?
我试过这段代码,但它不起作用。我相信它应该在 '$x = 2';
行产生警告错误# Do this at the beginning of the script
BEGIN {
if ( $ARGV[0] =~ /^Y$/i ) {
use strict;
use warnings;
}
else {
no strict;
no warnings;
}
}
$x = 2;
print "x is $x\n";
目的是仅在开发中启用警告消息。
【问题讨论】:
标签: perl