O'Reilly Hacks
oreilly.comO'Reilly NetworkSafari BookshelfConferences Sign In/My Account | View Cart   
Book List Learning Lab PDFs O'Reilly Gear Newsletters Press Room Jobs  


EMAIL HACK

Dave Barry latest column email service.
In the same way m-w.com or dictionary.com has Word-of-the-day services, I thought it'd try it out with Dave Barry's columns.

Contributed by:
C M
[09/07/04 | Discuss (0) | Link to this hack]

"Dave Barry is a humor columnist for the Miami Herald. His column appears in more than 500 newspapers in the United States and abroad. In 1988 he won the Pulitzer Prize for Commentary. Many people are still trying to figure out how this happened.

Dave has also written a total of 25 books, although virtually none of them contain useful information. Two of his books were used as the basis for the CBS TV sitcom "Dave's World," in which Harry Anderson played a much taller version of Dave."

-- http://www.davebarry.com/about.html

#!/usr/bin/perl

use Mail::Sendmail;
#
#   Gets the latest Dave Barry column and emails it to people.
#
$bcc = 'first@email.com, second@email.com, etc...';
$from = 'your@email.com';
$subject= "Latest Dave Berry Column";
$wget = "/usr/bin/wget";
##
##   Don't change anything below....
##
$data = `$wget -q -O - http://www.miami.com/mld/miamiherald/living/columnists/dave_barry/`;
$data =~ s/\n/@@/g;
$data =~ s/img src=(@@)*"/img src="http:\/\/www.miami.com\//g;
$data =~ s/a href="/a href="http:\/\/www.miami.com\/mld\/miamiherald\/living\/columnists\/dave_barry\//g;
$match = "";
if ($data =~ /LATEST COLUMN(.*?)DAVE BARRY/ ){
	$match = $1;
	$match =~ s/@@/\n/g; #print "$match\n";
	$match .= "DAVE BARRY</span><br>";
	%mail = ( From => $from, Bcc => $bcc, Subject => $subject, Message => $match );
	$mail{'content-type'} = "text/html";
    sendmail(%mail) or die $Mail::Sendmail::error;
    print "$match\n";
}

See also: http://www.oreillynet.com/pub/h/1829


O'Reilly Home | Privacy Policy

© 2007 O'Reilly Media, Inc.
Website: | Customer Service: | Book issues:

All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners.