I want to read UTF-8 input in Perl, no matter if it comes from the standard input or from a file, using the diamond operator: while(<>){...}
.
So m
Your script works if you do this:
#!/usr/bin/perl -w
binmode STDOUT, ':utf8';
while(<>){
binmode ARGV, ':utf8';
my @chars = split //, $_;
print "$_\n" foreach(@chars);
}
The magic filehandle that <> reads from is called *ARGV
, and it is
opened when you call readline.
But really, I am a fan of explicitly using Encode::decode
and
Encode::encode
when appropriate.