perl-unicode

Problem using Unicode::UCD casefold and casespec.

2003-05-10 09:30:25

I'm trying to use casefold and/or casespec from Unicode::UCD and seem
to be running into some basic problem. This is perl, v5.8.0 built for
i386-linux-thread-multi on Mandrake 9.1 and I have an up-to-date
Unicode::UCD according to CPAN. Unicode::UCD::UnicodeVersion() returns
3.2.0.

My first problem is that the docs for both casefold and casespec tell
me the functions return a ref to a hash but illustrate usage as

    my %casefold = casefold("09dc");

This gets you the "odd number of elements in hash" error message that
you'd expect if the function does indeed return a ref to a hash.
Replacing with

    my $casefold = casefold("09dc");

I get no error.

However the problem with this is that $casefold comes back as undef.
So this script prints 'undef' (without the die line it prints nothing):

    #!/usr/bin/perl -w
    use strict;
    use Unicode::UCD 'casespec';

    my $c = casespec("09dc");

    die "undef\n" unless defined $c;

    foreach my $key (sort keys %$c){
        print "$key = $$c{$key}\n";
    }


Can someone let me know what I'm doing wrong here? I see the same
behavior when I use casespec too (which is also documented as
returning a ref to a hash but shown in sample usage examples with my
%casespec = casespec("09dc")).

Regards,
Terry