##
use warnings;
use strict;
open my $fh, '<', 'in.txt'
or die $!;
open my $wfh, '>', 'out.txt'
or die $!;
binmode $fh, ":utf8";
binmode $wfh, ":utf8";
binmode STDOUT, ":utf8";
while (<$fh>){
chomp;
print $wfh "file: $_\n";
print "stdout: $_\n";
}
####
# output file
file: }cýæu}*]…‘¦å
file: hello ›ÇÁ
# stdout
stdout: }cýæu}*]…‘¦å
stdout: hello ›ÇÁ