perl-unicode

Looping with Unicode

2003-03-06 17:30:09
Greetings,

I seem to remember in the past, possibly with a development
version of Perl, that unicode chars in utf-8 worked fine as
loop iterators, as per:

foreach (<a>..<z>) {  do something }

where <a> and <z> are single characters in utf-8.  With Perl
5.8.0 the loop cycles only once.  Is this a bug or by design?
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
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;").

thanks!

/Daniel

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