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.
And here is an example of the format for the vocabulary list: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; }
deem abate aberrant abscond accolade acerbic acumen adulation adulterate aesthetic aggrandizeetc. (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 | |
|
Re: Daily Vocabulary Mailer
by mt2k (Hermit) on May 27, 2002 at 04:06 UTC |