autodie-pragma对编码有影响吗? [英] Does the autodie-pragma have influence on the encoding?

查看:174
本文介绍了autodie-pragma对编码有影响吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么我得到autodie不同的输出?

Why do I get after the "autodie" a different output?

#!/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


推荐答案

除非有更好的理由进入,否则这看起来像 autodie 相对于打开 pragma。

Unless someone comes in with a better reason, this looks like a bug with autodie in relation to the open pragma.

将最后一次打开更改为打开我的$ fh2,'<:utf8' ,'test.txt'; 修复了我的系统上的问题。所以这可能是一个临时工作。

Changing the last open to open my $fh2, '<:utf8', 'test.txt'; fixes the problem on my system. So that could be a temporary work around.

我刚刚检查了RT,这是一个注册的错误:

I just checked RT, and this is a registered bug:

https://rt.cpan.org/Public/Bug/Display。 html?id = 54777

看起来它与每个pragma都使用不同的方式重载打开函数。

Looks like it has to do with each pragma using different ways of overloading the open function.

这篇关于autodie-pragma对编码有影响吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆