perl – autodie-pragma对编码有影响吗?

为什么我会得到“autodie”不同的输出
#!/usr/bin/env perl
use warnings;
use 5.012;
use utf8;
use open ':encoding(utf-8)';
use open ':std';

open my $fh,'>','test.txt' or die $!;
say $fh 'käse';
close $fh;

open my $fh1,'<','test.txt' or die $!;
while ( my $row = readline( $fh1 ) ) {
    print $row;
}
close $fh1;

use autodie;

open my $fh2,'test.txt';
while ( my $row = readline( $fh2 ) ) {
    print $row;
}
close $fh2;

# Output:
# käse
# käse

解决方法

除非有更好的理由进入,否则这看起来像一个与开放伪指令有关的bug。

改变最后一次打开我的$ fh2,’<:utf8','test.txt';解决我的系统上的问题。所以这可能是临时工作。 我只是检查了RT,这是一个注册错误https://rt.cpan.org/Public/Bug/Display.html?id=54777

看起来它与每个pragma都使用不同的方法来重载open函数

相关文章

1. 如何去重 #!/usr/bin/perl use strict; my %hash; while(...
最近写了一个perl脚本,实现的功能是将表格中其中两列的数据...
表的数据字典格式如下:如果手动写MySQL建表语句,确认麻烦,...
巡检类工作经常会出具日报,最近在原有日报的基础上又新增了...
在实际生产环境中,常常需要从后台日志中截取报文,报文的形...
最近写的一个perl程序,通过关键词匹配统计其出现的频率,让...