use strict;
use warnings;
use XML::Simple;

while (my $subfile = shift @ARGV)
{
    my $subs = XMLin($subfile);
    visitItems($subs->{'body'}, \&printSubscriptions);
}

sub visitItems
{
my ($ref, $subRef) = @_;
for my $item (@{$ref->{'outline'}})
{
    &$subRef($item);
    if (ref($item->{'outline'}) eq 'ARRAY')
    {
        visitItems($item, $subRef);
    }
}
}

sub printSubscriptions
{
my ($item) = @_;
# This is a less verbose (but more confusing?) way to do the next 5 declarations.
#    my ($html, $title, $rss, $type, $description) =
#    map { $item->{$_} } (qw(htmlUrl title xmlUrl type description));
my $html = $item->{'htmlUrl'};
my $title = $item->{'title'};
my $rss = $item->{'xmlUrl'};
my $type = $item->{'type'};
my $description = $item->{'description'};
print qq{<p>};
print qq{<a href="$html">} if ($html);
print (($title) ? $title : $html || $rss);
print qq{</a> } if ($html);
print qq{ <em>$description</em>} if ($description);
print qq{ <a href="$rss"><img
             src="http://corky.net/dotan/log/images/xml.gif"
             width="36" height="14"
             alt="RSS"></a>} if $rss;
print qq{</p>\n };
}