use charnames ":full"; binmode(STDOUT, ":utf8"); %mapUnicode = (); open(MAP, "map2.txt") or die "!"; while() { next if (/^#/); next if ($_ !~ /[A-Z]/); chomp; if (length $_ > 0) { my @mapInfo = split / ### /; $mapUnicode{"$mapInfo[0]"} = $mapInfo[2]; } } close(MAP); open IN, "greekwords1.txt" or die "!"; open OUT, ">:utf8", "greekwords2.txt"; $buffer = ""; while() { chomp; my $word = $_; print "\nWord is $word\n"; while($word =~ m/(.)/g) { my $newPart = $1; my $prospectiveUnit = "$buffer$newPart"; if (exists $mapUnicode{$prospectiveUnit}) { $buffer = $prospectiveUnit; } else { my $symbolName = $mapUnicode{$buffer}; print "Writing $buffer as $symbolName\n"; print OUT chr(charnames::vianame("$symbolName")); $buffer = "$newPart"; } } my $symbolName = $mapUnicode{$buffer}; print "Writing $buffer as $symbolName\n"; print OUT chr(charnames::vianame("$symbolName")); $buffer = ""; print OUT "\n"; } close IN; close OUT;