2011-02-10 9 views
16

"autodie"の後に別の出力が表示されるのはなぜですか?autodie-pragmaはエンコーディングに影響しますか?

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

答えて

17

誰かがより良い理由で来ていない限り、これはopenプラグマとの関係でautodieとバグのように見えます。

最後のオープンをopen my $fh2, '<:utf8', 'test.txt';に変更すると、私のシステムで問題が解決されます。だから、それは一時的な回避策かもしれません。

私はちょうどRTをチェックし、これは、登録されたバグです:それはopen機能を過負荷の異なる方法を使用して、各プラグマに関係しているよう

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

が見えます。

+1

私はそのバグのパッチを作成しました。 https://github.com/pfenwick/autodie/pull/12 – Schwern

関連する問題