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

前端之家收集整理的这篇文章主要介绍了perl – autodie-pragma对编码有影响吗?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
为什么我会得到“autodie”不同的输出? @H_301_2@#!/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函数

猜你在找的Perl相关文章