I got a Dvorak keyboard for Christmas this year. It came with a typing tutor, but it didn't give me the type of real-world practice that I needed. So I wrote this.
The "words" file is just linux's dict file, and the quotes.txt file is a list of about 5000 one-line jokes.
In addition to verifying the correctness of your keyboarding, it also times you, and gives you a rough count of your typing speed.
################################################
#
# Typing Tutor
#
# Throws up random words or quotes,
# and then checks the re-typing of them.
#
# v0.1 by Jeremy Gross, jeremy@cwes.net
#
################################################
use Time::local;
while (1) {
print <<EOA;
Typing Tutor
-=-=-=-=-=-=-=-=-=-=-
1) Words
2) Quotes/Jokes
3) Exit
EOA
;
print "What'll it be? ";
chomp( $choice = <STDIN> );
if ( $choice == 1 ) {
print "\n\n\n";
Words();
}
if ( $choice == 2 ) {
print "\n\n\n";
Quotes();
}
if ( $choice == 3 ) {
exit;
}
}
sub Words {
MAIN: while (1) {
open(WORDS, "words.txt") or print "Couldn't open word file: $!";
srand;
rand($.) < 1 && ($line = $_) while <WORDS>;
chomp $line;
print "Word: $line\n";
print "Retype: ";
chomp( $typed = <STDIN> );
if ( $typed eq "." ) { last MAIN; }
elsif ( $typed eq $line ) {
print "Good!\n\n";
}
else {
print "WRONG!!!\n\n";
push (@wrong, $line);
}
close(WORDS);
}
}
sub Quotes {
$totalsecs = 0;
$totalwords = 0;
$totallines = 0;
MAIN: while (1) {
open(QUOTES, "quotes.txt") or print "Couldn't open quotes file:
+$!";
srand;
rand($.) < 1 && ($line = $_) while <QUOTES>;
chomp $line;
$time1 = localtime;
@fields1 = split(/\s+/, $time1);
# print "$fields1[3]\n";
($hour,$min1,$sec1) = split(/:/, $fields1[3]);
print "Word: $line\n";
print "Retype: ";
chomp( $typed = <STDIN> );
$time2 = localtime;
# print "$fields2[3]\n";
@fields2 = split(/\s+/, $time2);
($hour,$min2,$sec2) = split(/:/, $fields2[3]);
$sec1 += $min1 * 60;
$sec2 += $min2 * 60;
$SEC = $sec2 - $sec1;
if ( $typed eq "." ) { last MAIN; }
elsif ( $typed eq $line ) {
print "Good!\n";
$totalsecs += $SEC;
@temp = split(/ /, $typed);
$totalwords += scalar @temp;
$wpm = ($totalwords / ($totalsecs / 60));
print "Time: $SEC seconds Average: $wpm Words/Minute\n\n";
}
else {
print "WRONG!!!\n";
$totalsecs += $SEC;
@temp = split(/ /, $typed);
$totalwords += scalar @temp;
$wpm = ($totalwords / ($totalsecs / 60));
print "Time: $MIN:$SEC Average: $wpm Words/Minute\n\n";
push (@wrong, $line);
}
close(QUOTES);
}
}