#-*-Perl-*-

#Add the name of the subroutines to the hash of functions
#with the number of days from today the comic is available
$hof{"me"} = 0;

sub me {
    my $time = shift;
    my @ltime = gmtime($time);
    my @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
    my $month = $ltime[4];
    my $day = $ltime[3];
    my $year = $ltime[5]+1900;
    my $daysago = (time - $time)/(3600*24);
    $daysago =~ s/\..*$//;
    
    return undef 
      if ($daysago > 7 || 
        $ltime[6] == 0);

    my $rec = {
      'title' => "Madam and Eve",
  	  'author' => "S. Francis, H. Dugmore, & Rico",
      'main' => "http://www.madameve.co.za/",
      'archives' => "http://www.madameve.co.za/archive.html",
      'base' => "http://www.madameve.co.za/",
      'page' => "todays.php",
      'size' => [600,191],
    };
    $rec->{'func'} = sub {
 	  my $text = shift;
      my @relurls = ();
      if ($text =~ s/$day\s+?$months[$month]\s+?$year.+?SRC="(toondb\/cartoons\/me\d*?\.((jpg)|(gif)|(png)))"//i) {
        push(@relurls,$1);
        $rec->{'type'} = $2;
      }
      return reverse @relurls;
    };
    return $rec;
}

1;
