Dear Monks, I've been following some suggestions regarding automating an RSS feed and have begun adapting some code that Merlyn pointed me towards on his site. It should read an RSS feed and then email out anything that is new (I realise that dbmopen is old code and tie is preferred - that's next). For some reason, if a new post comes in, then the whole file is being emailed and not just the new post which is what I had hoped. Could anybody please let me know what I've done incorrectly (since if there are no new posts then no email).
use strict; use warnings; use LWP::Simple; use LWP::UserAgent; use XML::LibXML; my $DIR = "C:\\Webroot\\rdf"; my $from = 'me'; my $to = 'me'; my $subject = "tweeting annoying"; my $ticket = qw(localhost/rss); my @news = ("localhost/rss", => "TestList",); chdir $DIR or die "Cannot chdir $DIR: $!"; my @output; while (@news >= 2) { my ($url, $localname) = splice @news, 0, 2; dbmopen my %SAW, $localname, 0644 or warn "Cannot open %SAW for $lo +calname: $!"; my $feed = get($ticket); my $parser = XML::LibXML->new; my $doc = $parser->parse_string($feed); my %seen; my @item_output; for my $item($doc) { my $date = $doc->findvalue('rss/channel/item/pubDate'); my $desc = $doc->findvalue('rss/channel/item/description'); $seen{$date} = localtime; next if $SAW{$date}; push @item_output, $desc; } %SAW = %seen; if (@item_output) { push @output, @item_output; } } if (@output) { require Net::SMTP; my $smtp = Net::SMTP->new(Host => 'mailhost'); $smtp->mail( $from ); $smtp->to( $to ); $smtp->data(); $smtp->datasend("To: $to\n"); $smtp->datasend("From: $from\n"); $smtp->datasend("Subject: $subject\n"); $smtp->datasend("\n"); # done with header $smtp->datasend("@output\n"); $smtp->dataend(); $smtp->quit(); # all done. message sent. }
All I'm trying to get is the description as it contains all the necessary information I need. MTIA for any help.

In reply to Automating an RSS feed by Quicksilver

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.