#! /usr/bin/perl -w

# Setup includes
use strict;
use XML::RSS;
use LWP::Simple;

# Declare variables for URL to be parsed
my $url2parse;

# Get the command-line argument
my $arg = shift;

# Create new instance of XML::RSS
my $rss = new XML::RSS;

# Get the URL, assign it to url2parse, and then parse the RSS content
$url2parse = get($arg);
die "Could not retrieve $arg" unless $url2parse;
$rss->parse($url2parse);

#
# Print the channel items
print "<HTML>\n";
print "<HEAD>\n";
print "    <META HTTP-EQUIV=\"refresh\" content=\"60; URL=file:\\\\C:\\Documents and Settings\\gerardvw\\Favorites\\Favorites.html\">\n";
print "    <TITLE>RSS feed</TITLE>\n";
print "</HEAD>\n";
print "<BODY>\n";
print "    <UL>\n";

foreach my $item (@{$rss->{'items'}}) {

     next unless defined($item->{'title'}) && defined($item->{'link'}) && defined($item->{'description'});
     print "\t<LI><A HREF=\"$item->{'link'}\">$item->{'title'}</A><BR>$item->{'description'}</BR></LI><BR></BR>\n";

}

print "    </UL>\n";
print "</BODY>\n";
print "</HTML>\n";
