while ($string=~m{(B|C|P|T|Z|a|b|d|h|k|n|p|q|u|v|x)}g){
$count=$count+($tbsz*0.5625);
}
####
while ($string=~m{[BCPTZabdhknpquvx]}g){
$count+=($tbsz*0.5625);
}
####
my %start_table = (
'\s' => 1,
'' => 1,
'<195>' => 1,
'\.' => 0.25,
'' => 0.25,
'<193>' => 0.25,
'' => 0.5,
'<194>' => 0.5,
);
my $start_lookup = join '|', keys %start_table;
my %ftype_table = (
W => 1,
'\s' => 1,
'%' => 1, ### % is added temporarily for some testing purpose
w => 0.84375,
'\)' => 0.84375, ### need to escape meta-characters!!!
'\(' => 0.84375,
M => 0.8125,
m => 0.8125,
N => 0.7188,
Q => 0.7188,
# etc,
);
my $ftype_lookup = join '', keys %ftype_table;
my %non_ftype_table = (
W => 0.7844,
w => 0.6999,
A => 0.5656,
X => 0.55,
Q => 0.5469,
O => 0.5469,
R => 0.5375,
K => 0.5375,
Y => 0.5375,
# etc.
);
my $non_ftype_lookup = join '' keys %non_ftype_table;
while ( $string =~ /($start_lookup)/og ) {
$count += $tbsz * $start_table{ $1 };
}
$string =~ s/<[A-Z\[\\\]\^_`a-z]+>//g;
if ( $ftype == 1 ) {
while ( $string =~ /([$ftype_lookup])/og ) {
$count += $tbsz * $ftype_table{ $1 };
}
else {
while ( $string =~ /([$non_ftype_lookup])/og ) {
$count += $tbsz * $non_ftype_table{ $1 };
}
}