Acme-Mobile-Therbligs
view release on metacpan or search on metacpan
- corrections to POD
- added SEE ALSO section for similar module
0.02 Sun Jan 2 20:07:00 2005
- added more tests
- added option for NO_SHIFT
- updated documentation
- added ability to change options in constructor
- added option for NO_SENTENCE_CAPS
- added case flag to count function
- added debug flag to count function
0.01 Fri Dec 31 14:10:24 2004
- original version; created by h2xs 1.23 with options
-n Acme::Mobile::Thurblings -v 0.01 -X -P -b 5.6.0
lib/Acme/Mobile/Therbligs.pm view on Meta::CPAN
keystrokes to toggle the shift key. It assumes that the first letter
of the message or a sentence is capitalized. (If C<$case_flag> is
unspecified, it is assumed to be false.)
=cut
sub count_therbligs {
my $self = shift;
my $text = shift;
my $case = shift;
my $debug = shift; # for diagnostics
unless (ref($self)) {
($debug, $case, $text, $self) = ($case, $text, $self, $Self);
}
my $last = ""; # last character
my $shift = 0; # shift flag
my $start = $case; # sentence start flag
my $thurb = 0; # therblig count
foreach my $char (split //, $text) {
if ($debug) {
print STDERR
"# last=$last char=$char start=$start shift=$shift thurb=$thurb\n";
}
unless ($self->{NO_SHIFT_CAPS}) {
# Note: it assumes characters are lower-case rather than
# upper-case without shifting.
if ($char ne lc($char)) {
lib/Acme/Mobile/Therbligs.pm view on Meta::CPAN
croak "Unknown character: $char",
unless (exists $self->{CHAR}->{$char});
$thurb += $self->{CHAR}->{$char}->[1];
$thurb += $self->{SAME_KEY},
if ($self->{CHAR}->{$char}->[0] eq ($self->{CHAR}->{$last}->[0]||""));
$last = $char;
}
if ($debug) {
print STDERR
"# last=$last char= start=$start shift=$shift thurb=$thurb\n";
}
return $thurb;
}
=back
( run in 0.972 second using v1.01-cache-2.11-cpan-49f99fa48dc )