Acme-Mobile-Therbligs
view release on metacpan or search on metacpan
0.03 Wed Jan 5 2005
- 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
{
$Self = __PACKAGE__->new(undef, {
SAME_KEY => DEFAULT_SAME_KEY,
NO_SENTENCE_CAPS => 0,
NO_SHIFT_CAPS => 0,
});
}
=item count_therbligs
$count = count_therbligs($message, $case_flag);
$count = $obj->count_therbligs($message, $case_flag);
Returns the number of "therbligs" (keystrokes) used to generate the
message. A therblig is either a keystroke, or the pause when one has
to wait in order to enter multiple letters from the same key (such as
with the word "high").
The default number of therbligs for waiting in the same key is
C<1>. There is no way to change that value for this version.
When C<$case_flag> is true, the number of therbligs includes
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}) {
( run in 3.544 seconds using v1.01-cache-2.11-cpan-94b05bcf43c )