So, i have to take the GRE this summer to get into grad school. In order to prepare for the verbal section, i have obtained a list of 259 vocabulary words that a certain study guide deams worthy of memorizing. I figure that if i really concentrate on 10 words a day while studying other sections, i should do fine. And what a fun way it would be to pick 10 random words and have them emailed to me each day.

This script uses Tie::File, LWP::Simple, and Mail::Sendmail to grab 10 random words from my list, fetch and extract the definitions from dictionary.com, and then mail them to my email account. Rather than use a CPAN module on the HTML extraction requirement, i instead chose to simply use some regexes because it really took me less time (i need to be studying, not programming ;)). Also, the list i use is a copy of the original, because each run of this script removes the words it picks.

use strict; use Tie::File; use LWP::Simple; use Mail::Sendmail; my $MAX = 10; my $to = '<INSERT TO ADDRESS>'; my $from = '<INSERT FROM ADDRESS>'; my $file = '/path/to/vocabulary_list_copy.txt'; my @file; tie @file, 'Tie::File', $file or die $!; for (1..$MAX) { my $word = splice(@file, rand(@file), 1) or next; my $html = get("http://www.dictionary.com/search?q=$word"); my ($def) = $html =~ /<!-- Content -->(.*)<!-- End content -->/s; $def =~ s/<(?:no)?script.*<\/(?:no)?script>//sig; $def =~ s/(<\/table>(?!.*<\/table>)).*$/$1/sg; my %mail = ( To => $to, From => $from, Subject => $word, Message => $def, ); $mail{'Content-type'} = 'text/html; charset="iso-8859-5"'; sendmail(%mail) or die $Mail::Sendmail::error; sleep 2; }
And here is an example of the format for the vocabulary list:
deem
abate
aberrant
abscond
accolade
acerbic
acumen
adulation
adulterate
aesthetic
aggrandize
etc. (you can get the whole list here.) Not a lot of error checking and no 'rolling-back' in case the mail server does not send the email, but it works well enough for me. I run this as a cron job each morning before i wake up.

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Replies are listed 'Best First'.
Your friendly neighborhood spelling nazi :-)
by boo_radley (Parson) on May 27, 2002 at 03:52 UTC
    jeffa sez :
    In order to prepare for the verbal section, i have obtained a list of 259 vocabulary words that a certain study guide deams worthy of memorizing

    heh, heh.
    Normally nothing to comment on, but I thought the context this misspelling was made in was particularly amusing.

    oh, the script's neat, too :)

Re: Daily Vocabulary Mailer
by mt2k (Hermit) on May 27, 2002 at 04:06 UTC
    To support boo_radley's comment...:

    push @file, "deem";

    As long as I never have to memorize that many new words, I shall make fun of that mistake! If I ever DO need to do this, then I will aid you in pointing at me and laughing ;)