#-*-Perl-*-

#Tack on the names of the subroutines to the list of functions
$hof{"doodie"} = 0;

#Doodie http://www.doodie.org/
sub doodie {
    my $today = shift;
    my @ltime = localtime($today);
    my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = @ltime;
    return undef if $wday == 0 || $wday == 6; #none on Sat or Sun

    my $t_day = strftime("%Y%m%d",@ltime);
    my $n_day = strftime("%Y%m%d",localtime(time));
    my $get_todays = ($t_day == $n_day) ? 1 : 0;
    $mon++;
    #Because the retrieved webpages are being treated as a single line
    #in netcomics when being matched on, .*? is used for matching the
    #mimimum possible.  See the backtracking section in the perlre manpage
    my $gif_expr = "$mon\\.$mday\\.$year.*?(images.*?gif)";
    my %rec;
    $rec{'name'} = strftime("Doodie-${date_fmt}.gif",@ltime);
    $rec{'base'} = "http://www.doodie.com/";
    if ($get_todays) {
	$rec{'page'} = "index.html";
	$rec{'exprs'} = [$gif_expr];
    } else {
	$rec{'page'} = "index.cfm?archives=1";
	$rec{'exprs'} = ["a href=\"(\\w+\\.html)\"><i>$mon\\.$mday\\.$year",
			 $gif_expr];
    }
    return \%rec;
}

1;
