#!/usr/bin/perl -w
# vim: set sw=4 ts=4 si et:
# read one or more of the rss files
# and generate a list of links.
use strict;
require XML::RSS;
#
#
my @news = ();
my ($item,$site,$rdfstring);
my ($desc,$title);
my $rss = new XML::RSS;
die "USAGE: lglinks_short lg22.rss .....\nThe generated html code is written to stdout\n" unless($ARGV[0]);
#push (@news, "
Linux Gazette
\n");
#push (@news, "\n");
for my $file (@ARGV){
open(FF,$ARGV[0])||die "lglinks_short: ERROR can not read $file\n";
$rdfstring="";
while(){
s/&/+.+/g; # this is to fix a bug in the XML::RSS
$rdfstring.=$_;
}
close FF;
#
if ($rdfstring && length($rdfstring)> 250) {
$rss->parse($rdfstring);
#$rss->parsefile($file);
foreach $item (@{$rss->{'items'}}) {
if ($item->{'description'}){
$desc=$item->{'description'};
#print STDERR $desc."\n";
}else{
$desc="";
}
if ($item->{'title'}){
$title=$item->{'title'};
}else{
$title="<no title>";
}
push (@news, "- {'link'}\">$title
\n");
}
}else{
die "ERROR: failed to get news from $ARGV[0]\n";
}
}
#push (@news, "\n");
if (scalar(@news) < 5){
die "ERROR: less than 2 items \n";
}else{
for (@news){
s/\+\.\+/&/g;
print;
}
}
1;