#! /usr/bin/env perl
BEGIN{$^W=1} use strict;
use Data::Dumper;
use File::Basename;
use HTML::Entities;
use LWP::Simple;
#use Time::ParseDate;
use lib dirname($0); # look in the same directory that this script resides in
use FeedHelpers; # Common code, available here: http://paperlined.org/rss/feeds/FeedHelpers.pm
(my $feed = $0) =~ s#(^.*/|\.gen\.pl$)##g;
# Load the persistent data
my $persistent = PersistentHash::tie_storable("$feed.db");
#############################################
# Load the main page, parse posts
#############################################
my $main_page = conditional_http_simple_get('http://www.fark.com/index.html', $persistent)
or die "Unable to fetch Fark main page.\n\t";
my @stories;
while ($main_page =~ m#(.*?).*?{STORY_IMG}{$link}) {
print "Fetching $link...\n";
my $story = get($link);
#my $firstprost;
#($firstprost) = ($story =~ m#