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;
In reply to Re: Automating an RSS feed
by Your Mother
in thread Automating an RSS feed
by Quicksilver
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |