Skip to content

Instantly share code, notes, and snippets.

@samcv
Created January 13, 2017 04:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samcv/9555fb141eca8f0da718fd6e26a0620f to your computer and use it in GitHub Desktop.
Save samcv/9555fb141eca8f0da718fd6e26a0620f to your computer and use it in GitHub Desktop.
my $folder = "UNIDATA";
#my $names = slurp "$folder/NameAliases.txt";
my %points;
# NameAliases.txt
# 0 Codepoint (Hex)
# 1 NameAlias
# 2 NameAlias type
# sub path($cp, +@a) { say "\@.perl: @a.perl()"; @a.reduce({ $^a{$^b}:exists ?? $^a{$^b} !! $^a{$^b} = {} }) };
sub read-file ( $property, $file ) {
my $file-txt = slurp "$folder/$file.txt";
for $file-txt.lines {
next if .starts-with('#') or .match(/^\s*$/);
my @parts = .split(';');
my %hash;
%hash{@parts[0]}{$property}{@parts[1]}<type> = @parts[2];
apply-to-cp(%hash)
}
}
read-file("NameAlias", "NameAliases" );
sub apply-to-cp ($hashy) {
for $hashy.kv -> $key, $value {
my $cp = $key.parse-base(16);
say $hashy if $cp == 0;
%points{$cp} = $value;
}
}
say %points{0}.perl;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment