#-*-Perl-*-
#Tack on the names of the subroutines to the list of functions
$hof{"sluggy"} = 0;

#Sluggy Freelance: http://www.sluggy.com
sub sluggy {
    my @ltime = localtime(shift(@_));
    my $rec = {
	'name' => strftime("Sluggy_Freelance-${date_fmt}.gif",@ltime),
	'base' => "http://www.sluggy.com",
	};
    if ($ltime[6] != 0) {
	$rec->{'page'} = strftime("/comics/%y%m%da.gif",@ltime);
    } else {
	$rec->{'page'} = strftime("/archive/%y%m%d.html",@ltime);
	$rec->{'func'} = sub {
	    my $text = shift;
	    my $y = strftime("%y",@ltime);
	    my $m = strftime("%m",@ltime);
	    my $d = strftime("%d",@ltime);
	    my @relurls = ();
	    #example:
	    #<img src="/comics/990321b1.jpg" width=701 height=218><img src="/comics/990321b2.jpg" width=232 height=218>...
	    #repeatedly match and replace.  
	    while (1) {
		if ($text =~ /img src="(\/comics\/$y$m$d\w\d\.jpg)"/i) {
		    push(@relurls,$1);
		    #now replace the text so we don't match on it again
		    $text =~ s/img src="(\/comics\/$y$m$d\w\d\.jpg)"//i;
		} else {
		    last;
		}
	    }
	    return @relurls;
	}
    }
    return $rec;
}

1;
