Skip to content

Instantly share code, notes, and snippets.

@roberto
Created April 6, 2009 23:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roberto/91008 to your computer and use it in GitHub Desktop.
Save roberto/91008 to your computer and use it in GitHub Desktop.
typing training
#!/usr/bin/perl -w
use Time::HiRes qw(time);
use Data::Random::WordList;
my $word_list = new Data::Random::WordList(wordlist => '/usr/share/dict/words');
my @targets = $word_list->get_words(5);
$start_time = $jam_count = $errors_count = 0;
foreach $target (@targets) {
do {
system('clear');
$errors_count++ ;
print $target . "\n";
$start_time = time;
} while(<> !~ /^$target$/);
$jam_count++ if (time - $start_time) <= 1;
$errors_count--;
}
print "JAM x" . $jam_count . "\n";
print "ERRORS x" . $errors_count . "\n" if $errors_count > 0;
$word_list->close();
exit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment