#!/usr/bin/perl

$path = "/share/bread/www-data/html/GO/email/go-arc";
$query_string = $ENV{'QUERY_STRING'};

($key, $type) = split (/=/, $query_string);

$max = 2;

opendir(DIR, $path);

foreach $file (readdir(DIR)) {
    if ($file =~ /$type\d+\.html/) {
	($curr) = ($file =~ /$type(\d+)/);
	if ($curr > $ max) {
	    $max = $curr;
	}
    }
}

closedir(DIR);

print "Location: http://www.geneontology.org/email/$type$max.html\n\n";

return (0);
