##
binmode(STDIN, ':encoding(UTF-8)');
while () {
...
}
## ##
use Encode qw( decode );
open(my $fh, '<', $language_qfn) or die;
while (<$fh>) {
$_ = decode('UTF-8', $_);
...
}
####
open(my $fh, '>:encoding(UTF-8)', $output_fqn) or die;
print $fh ($text);
####
binmode(STDOUT, ':encoding(UTF-8)');
print($text);
####
use Encode qw( encode );
open(my $fh, '>', $output_fqn) or die;
print $fh (encode('UTF-8', $text));