#!/usr/bin/perl -w use strict; use feature qw( :5.10 ); use Carp; my $file = q{./yard}; open my $IN, '<:encoding(ISO8859-1)', $file or croak; binmode STDOUT, ":utf8"; # assuming your terminal is UTF-8 while (my $l = <$IN>) { # $l is now a Unicode/text string chomp $l; say "1: $l"; say "2: ", xlc($l); } ... sub xlc as you have it