加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

在perl的autodie.pm错误?

发布时间:2020-12-15 21:24:47 所属栏目:大数据 来源:网络整理
导读:我期待: #!/usr/bin/perluse autodie;# autodie in effect here{ no autodie; # autodie is not in effect here}# autodie should be in effect here because of the supposedly lexical scope# of autodie,but this doesn't die:open my $i,'','/nonexiste
我期待:
#!/usr/bin/perl
use autodie;
# autodie in effect here
{
    no autodie;
    # autodie is not in effect here
}
# autodie should be in effect here because of the supposedly lexical scope
# of autodie,but this doesn't die:
open my $i,'<','/nonexistent';

我基于perldoc autodie说:

The “autodie” pragma has lexical scope,meaning that functions and
subroutines altered with “autodie” will only change their behaviour
until the end of the enclosing block,file,or “eval”

此外,{no autodie}(在范围内)甚至是SYNOPSIS的一部分

使用/无警告的行为,如我所料:

#!/usr/bin/perl
use warnings;
{
    no warnings;
}
# This *does* generate a warning
print undef;

我错过了什么或者你同意在autodie有一个错误?我在autodie buglist没有找到什么

This is perl,v5.10.1 (*) built for i486-linux-gnu-thread-multi

编辑:我现在提交a bug report

解决方法

我可以用v5.10.0(Debian x86_64)和ActiveState 5.14.2重现这个。

尝试this location的错误报告。

编辑我测试了一些:绕过问题,直到bug被修复,你将需要再次使用autodie:

use strict;
use autodie;

do {
    no autodie;
    # ...
} while(0);

use autodie;

open FILE,'/non-existing'; # dies again.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读