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)

In reply to Daily Vocabulary Mailer by jeffa

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.