G'day csthflk,

Firstly, here's working code (written and run on Mac OS X) that does what you want. See the Notes at the end for details of what I did differently and why.

#!/usr/bin/env perl use strict; use warnings; use autodie; use charnames ':full'; my $in_map = 'pm_unicode_1061453_map2.txt'; my $in_words = 'pm_unicode_1061453_greekwords1.txt'; my $out_greek = 'pm_unicode_1061453_greek_out.txt'; my $in_map_re = qr{^([^#]+)\s###[^#]+###\s([^#]+?)\s*$}; open my $in_map_fh, '<', $in_map; my %uni_map = map { /$in_map_re/ ? ($1 => $2) : () } <$in_map_fh>; close $in_map_fh; open my $in_words_fh, '<', $in_words; open my $out_greek_fh, '>:utf8', $out_greek; while (<$in_words_fh>) { chomp; my @word_chars = split ''; my $greek_word = ''; my $key = ''; while (@word_chars) { $key .= shift @word_chars; next unless exists $uni_map{$key}; next if @word_chars && exists $uni_map{join '' => $key, $word_ +chars[0]}; $greek_word .= charnames::string_vianame($uni_map{$key}); $key = ''; } die "Can't find charname for '$key'" if $key; print $out_greek_fh "$greek_word\n"; } close $in_words_fh; close $out_greek_fh;

I downloaded the input files with wget. They have the same line ending discrepancy that graff noted (above).

Here's the output. There's some issues with posting Unicode code with <code>...</code> tags; I've used <pre>...</pre> tags here.

$ cat pm_unicode_1061453_greek_out.txt
Θεωροῦντες
δὲ
τὴν
τοῦ

Notes:

-- Ken


In reply to Re: unicode issues on Unix only by kcott
in thread unicode issues on Unix only by csthflk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.