#-*-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 $time = shift;
    my @ltime = gmtime($time);
    my @ltime2 = gmtime(time);
    my $date = strftime("%y%m%d",@ltime);
    my $date2 = strftime("%Y%m%d",@ltime);

    # Last updated May 23, 2001
    my @missing = (20010806,20010807,20010808,20010809,20010810,20010811,
				   20010812);

    return undef 
      if (($date2 < 19970825) || #first comic on Aug 25, 1997
          grep(/$date/,@missing));

    my $rec = {
  	  'title' => "Sluggy Freelance",
	  'author' => "Pete Abrams",
	  'main' => "http://www.sluggy.com/",
	  'archives' => "http://www.sluggy.com",
	  'base' => "http://pics.sluggy.com",
      'page' => "/daily.php?date=$date",
    };

    $rec->{'func'} = sub {
 	 my $text = shift;
     my @relurls = ();
  	  #repeatedly match and replace.  
          while (1) {
            if ($text =~ s/src=".*?(\/comics\/.*?$date.*?\.((:?jpg)|(:?gif)|(:?png)))"//i) {
              push(@relurls,$1);
              $rec->{'type'} = $2;
              #last if ($date2 == strftime("%Y%m%d",@ltime2) && $ltime2[6] != 0);
            } else {
              last;
            }
          }
	  if ($text =~ s/selected>(.*?)<\/option>//i) {
        $rec->{'caption'} = $1;
      }

      return reverse @relurls;
    };
    return $rec;
}

1;
