#!/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; # Sort entries my @entries = sort { $b->issued <=> $a->issued } $feed->entries; # Print summary of five latest entries for my $entry (@entries[0..4]) { my $d = $entry->issued->strftime('%a, %e %B %Y %H:%M:%S UTC'); my $f = encode_entities decode('utf8', $entry->author); my $s = encode_entities decode('utf8', $entry->title); my $l = encode_entities $entry->link; print <
Date: $d
From: $f
$s
HTML }