#!/usr/bin/perl
use LWP::Simple;

$feed = get "http://www.slate.com/all.fulltext.all.rss"; #get "http://xkcd.com/rss.xml";
@lines = split(/</, $feed);

foreach $line (@lines) {
	if ($line =~ /^item>/) {
		#print "We are in the item element\n";
	}
	if ($line =~ /^title>(.*)/) {
		#print "Title:  $1\n";
		$title = $1;
	}
	if ($line =~ /^link>(.*)/) {
		#print "Link:  $1\n";
		$link = $1;
	}
	if ($line =~ /^description>(.*)/) {
		#print "Description: $1\n";
		$description=$1;
		$description =~ s/&amp;nbsp;/ /g;
		$description =~ s/&lt;/</g;
		$description =~ s/&gt;/>/g;
		if ($description =~ /src="(\S+)"/) {
			$desc_img = $1;
		}
		if ($description =~ /title="([^"]+)"/){
			$desc_title = $1;
		}
	}
	if ($line =~ /^\/item>/) {
		#print "Item element is ended\n";
		print "Title: $title\n";
		print "Description: $description\n";#$desc_title\n";
		#print "Image: $desc_img\n";
		print "Link: $link\n";
		print "\n\n";
	}
}