diff options
Diffstat (limited to 'run/rss')
-rw-r--r-- | run/rss | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -0,0 +1,34 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use HTML::Entities; +use XML::Feed; +use Encode qw(decode encode); + +my %feeds = ( + blogs => 'http://blogs.perl.org/atom.xml', + reddit => 'https://www.reddit.com/r/perl/.rss', + cpan => 'https://metacpan.org/feed/recent', +); +(my $name = $0) =~ s,.*/,,; + +my $feed = XML::Feed->parse(URI->new($feeds{$name})) + or die XML::Feed->errstr; +my @entries = $feed->entries; + +# Print summary of five latest entries +for my $entry (@entries[0..4]) { + my $d = encode_entities $entry->issued->ymd; + my $f = encode_entities decode('utf8', $entry->author); + my $s = encode_entities decode('utf8', $entry->title); + my $l = encode_entities $entry->link; + print <<HTML +<div class="entry"> +<div class="date">$d</div> +<div class="from">$f</div> +<div class="subject"><a href="$l">$s</a></div> +</div> +HTML +} |