#!/usr/bin/perl
#dumpfeed.pl - returns HTML code pulled from CJU.com RSS/Atom feed grabbers.
# use:
#
# require dumpfeed.pl
# $blog = dumpfeed('blog);
# print $blog;
sub dumpfeed {
# Configuration Hash uses key => value, where key is a keywork passed
# to the routine, specifying what feed you want and value is the file
# containing the feed contents
my %feeds = (
'blog' => 'blogfeed.txt',
'flckr' => 'flckrfeed.txt'
);
my $requestfeed = shift();
my $feedfile = $feeds{$requestfeed};
# Open the feed file
my $text;
my $failed;
open (F, "$feedfile") || ($failed = 1);
while ()
{
$text = $text . $_;
}
close F;
if ($failed == 1)
{
$text = "Error: Could not open feed with token $requestfeed using source $feedfile.";
}
# Send it back.
return $text;
}
1;