UTF-8 でエンコードされた xml ファイルを読み込もうとしています。このファイルのサイズは約 8M で、1 行しか含まれていません。
以下の行を使用して、この単一行の xml ファイルを開きました。
open(INP,"<:utf8","$infile") or die "Couldn't open file passed as input, $!";
local $/ = undef;
my $inputfile = <INP>;
print $inputfile; ## Not working..
しかし、このラインプログラムの後、スタックして待ち続けます。
binmode や decode などの他の方法を試しましたが、同じ問題が発生します。
上記のファイルを開くコードを次のように変更すると、同じプログラムが機能します。
open(INP,"$infile") or die "Couldn't open file passed as input, $!";
local $/ = undef;
my $inputfile = <INP>;
print $inputfile; ## It works..
open(INP,"$infile") or die "Couldn't open file passed as input, $!";
binmode(INP, ":utf8");
local $/ = undef;
my $inputfile = <INP>;
print $inputfile; ## Not working..
ここで私が間違っていることを教えてください。入力データに対して何らかの操作を実行する必要があり、utf8 でエンコードされた出力を取得する必要があります。