Chas. Owens wrote:
The easiest way I can think of is to build a (UTF-8) file named
itrans2unicode.table that looks like this
a => a
aa => ā
~N => ṅ
I have successfully created the file lookup.table containing lines as suggested
above with ASCII and Unicode characters separated by ' => '.
Then read that file into a hash at startup
Is there an easy way to do this directly?
When I read the file into a hash, I used ' => ' as a separator pattern for split
and key value assignments as shown below:
-----------
#!/usr/bin/perl -C24
use warnings;
use diagnostics;
use strict;
use utf8;
open my $fh, "<:utf8", "lookup.table";
my @lookup = <$fh>;
close $fh;
binmode STDOUT, ':utf8';
my %lookup = ();
foreach my $line (@lookup)
{
my ($key, $value) = split / => /, $line;
$lookup{$key} = $value;
print "$key => $lookup{$key}\n";
}
-----------
Is there another, easier way to load the file into a hash, using the already
existing => symbol in the file?
Otherwise, inserting the ' => ' seems a wasted effort. One could just as well
have used the original two column space or tab separated file and read it in
using the -a option and @F array to assign the ASCII symbol in column one to the
key and the Unicode symbol in column two to the value.
Thank you.
Chandra
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/