in reply to Automating an RSS feed

Here is something a bit more modern. See XML::Feed, DateTime, MIME::Lite, and friends.

use strict; use warnings; use XML::Feed; use MIME::Lite; use DateTime; use URI; my $uri = URI->new("http://news.google.com/news?q=perl&output=atom"); # parse can take raw xml, file names, and more my $feed = XML::Feed->parse($uri) or die XML::Feed->errstr; my $last_48 = DateTime ->now( time_zone => 'floating' ) ->subtract( hours => 48 ); exit unless 1 == DateTime->compare( $feed->modified, $last_48 ); my $body = ""; for my $entry ( $feed->entries ) { next unless 1 == DateTime->compare( $entry->modified, $last_48 ); $body .= "<h3>" . $entry->title . "</h3>\n"; $body .= "<div>" . $entry->content->body . "</div>\n"; } warn "No body... loves me!" unless $body; my $msg = MIME::Lite ->new( From => 'me@myhost.com', To => 'you@yourhost.com', Subject => $feed->title, Type => "text/html", Data => $body, ); print $msg->as_string, "\n"; # $msg->send;

Replies are listed 'Best First'.
Re^2: Automating an RSS feed
by davorg (Chancellor) on Aug 07, 2008 at 08:54 UTC
      Many thanks Davorg and Your Mother. As per above, I'm just experimenting with an older box where its always fun to add new modules. That and I wanted to see what goes on inside from curiosity. I'll certainly be exploring the newer code for any production purpose.