perl - 如何禁用警告?

标签 perl

我有警告:

"my" variable $subject masks earlier declaration in same scope at ...

我知道我可以通过 no warnings 'all' 禁用警告pragma,但找不到 right category对于我的警告类型。

如何仅禁用此类警告?

最佳答案

搜索 perldoc perldiag 为您的警告信息。这个turns up

"%s" variable &%s masks earlier declaration in same %s

(W shadow) A "my", "our" or "state" variable has been redeclared in the current scope or statement, effectively eliminating all access to the previous instance. This is almost always a typographical error. Note that the earlier variable will still exist until the end of the scope or until all closure references to it are destroyed.


它告诉您禁用此特定警告的编译指示是
no warnings 'shadow';

关于perl - 如何禁用警告?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61030447/

相关文章:

arrays - 如何在 perl 数组中对序列号进行分组?

perl - 需要与 CPAN 发行版一起安装的非 Perl 文件?

regex - 从逗号分隔的字符串中提取没有尾随空格的第二个单词的最易读的正则表达式是什么?

perl - 使用 Perl 和 GtkBuilder 连接信号

perl - 如何将子例程调用的结果分配给 Perl 中的数组引用?

mysqlimport:错误:1452

perl - 如何使用 Class::DBI->sequence() 方法在 perl 中自动填充 'id' 字段?

xml - 我应该如何在 Perl 中解析大型 XML 文件?

Perl 合并输出和 stderr 以及 Windows 中的过滤行

perl - 如何在 Perl 中测试 TCP 套接字状态?