perl-unicode

Re: Looping with Unicode

2003-03-07 09:30:04

Can something be set in the script to make it work as expected?

An observation;  UTF-8 keys in a hash can be defined without
quotation:

%myHash =(
      <abc> => "this",
      <xyz> => "that",
        :   :     :
);

but later the keys must be referenced in quoted form.  That

Hmmm, that *should* work under 'use utf8'.

is $myHash{'<abc>'} returns a value, $myHash{<abc>} does not.
This seems a little inconsistent and misleading.  I favor the
quoteless style myself.  Again, did I forget to set something?
(yes I did try "use utf8;").


What I think is happening is that without the quotes, the key is
treated as if the utf8 flag is off.  Why I'm lead to think this is
that when I print a list of keys (ala keys %myHash) the new keys
created after the initial hash definition appear as raw octets.
That is,

  $myHash{<newUtf8Key>} = ....;

The <newUtf8Key> key does not get the utf8 flag set on unless
the quotes were used.  So the problem with referencing an original
key w/o quotes must be the same problem.

/Daniel

<Prev in Thread] Current Thread [Next in Thread>