use strict; use Tie::File; use LWP::Simple; use Mail::Sendmail; my $MAX = 10; my $to = ''; my $from = ''; 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 =~ /(.*)/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; }