Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: Unicode combining characters as hash keys?

by Jim (Curate)
on Sep 02, 2011 at 22:32 UTC ( #923946=note: print w/replies, xml ) Need Help??

in reply to Unicode combining characters as hash keys?


binmode(STDOUT, ':encoding(UTF-8)');

…instead of…

binmode(STDOUT, ":utf8");

Likewise, use…

open HASH, '<:encoding(UTF-8)', 'test_hash.txt'; ... open INPUTFILE, '<:encoding(UTF-8)', 'test_input.txt';

…instead of…

open HASH, '<:utf8', "test_hash.txt"; ... open INPUTFILE, '<:utf8', "test_input.txt";

Also, this looks wrong to me:

my @word = $entry =~ /(\X)/g;

Shouldn't that be…

my @word = $entry =~ /(\X+)/g;


UPDATE: Upon reexamination, it looks right to me. :-/ Using the variable name @letters instead of @word would be an improvement, though. Then…

for my $letter (@letters) { my @input_features = @{ $hash{$letter} }; print join(" ", @input_features) . "\n"; }

Replies are listed 'Best First'.
Re^2: Unicode combining characters as hash keys?
by Anonymous Monk on Sep 03, 2011 at 08:20 UTC

    Thanks, Jim.

    I didn't understand the part you crossed out either at first. I didn't know using /.../g would return an array. But I found in the Perl Cookbook :-)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://923946]
[ambrus]: herecy! meat (especially ground meat) and tomato together is a great basic recipe for various foodstuff. it's dairy product based sauces and tomato sauce that don't belong together.

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2017-11-22 11:44 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (319 votes). Check out past polls.