| Lingua-Han-Stroke documentation | Contained in the Lingua-Han-Stroke distribution. |
Lingua::Han::Stroke - Retrieve the stroke count of Chinese character.
use Lingua::Han::Stroke;
my $stroke = Lingua::Han::Stroke->new();
print $stroke->stroke("ĪŅ"); # 7
any difficulty? send me email. :)
Fayland Lam, <fayland at gmail.com>
Please report any bugs or feature requests to
bug-lingua-han-stroke at rt.cpan.org, or through the web interface at
http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Lingua-Han-Stroke.
I will be notified, and then you'll automatically be notified of progress on
your bug as I make changes.
You can find documentation for this module with the perldoc command.
perldoc Lingua::Han::Stroke
You can also look for information at:
Copyright 2005 Fayland Lam, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Lingua-Han-Stroke documentation | Contained in the Lingua-Han-Stroke distribution. |
package Lingua::Han::Stroke; use warnings; use strict; use vars qw($VERSION); $VERSION = '0.07'; use File::Spec; use Lingua::Han::Utils qw/Unihan_value/; sub new { my $class = shift; my $dir = __FILE__; $dir =~ s/\.pm//o; -d $dir or die "Directory $dir nonexistent!"; my $self; my %st; my $file = File::Spec->catfile($dir, 'Stroke.dat'); open(FH, $file) or die "$file: $!"; while(<FH>) { my ($uni, $st) = split(/\s+/); $st{$uni} = $st; } close(FH); $self->{'st'} = \%st; return bless $self => $class; } sub stroke { my ($self, $hanzi) = @_; my $code = Unihan_value($hanzi); # got the Unihan field 1 return $self->{'st'}->{$code}; } 1; __END__