#!/usr/bin/perl

$db = "db.db.tokushima-u.ac.jp";
$output  = "achieve.tex";

$ystart = 1995;
$yend  = 2006;
@kind = (
"Academic Paper", 
"Academic Letter", 
"Proceeding of International Conference", 
"Proceeding of Domestic Conference", 
"Et cetera, Workshop"
);


@kind0 = @kind;

open F, ">$output" or die "cannot open $output\n";

$doc = <<END;
\\documentclass{jarticle}
\\usepackage{html}
\\title{Achievements}
\\author{\\htmladdnormallink{Tetsushi Ueta}{http://risa.is.tokushima-u.ac.jp}}
\\begin{document}
\\maketitle

This list is automatically extracted from 
\\htmladdnormallink{EDB}{http://web.db.tokushima-u.ac.jp}, Tokushima
University, and processed by Perl, \\LaTeX2HTML. 

END
print F $doc;

while ($x = shift(@kind0)){
	$t++;
	print F "\\section{$x}\n\\begin{enumerate}\n"; 
	for ($k = 0, $y = $ystart; $y <= $yend; $y++, $k++){
		$date = $y."0101"; $duration = $y."1299";
		print F "% date = $date, dur = $duration\n";
	$q = "whois -h $db 'DML=PLAIN LOOK=article.{@.author=person.{@.surname=\"Ueta\" @.givenname=\"Tetsushi\"} @.kind=articleattribute.{@.name=\"$x\"} @.date=\"$date $duration\" }' | perl -e 'while(<>){ if (/^[^!]/) { print \"\\\\item \$_\\n\";}  } '| /usr/local/bin/lv 2> /dev/null ";
		print F "%%%% $q\n";
		$ret = qx {$q};
		print F $ret; 
		#$_ = $ret;
		#while (/\\item/mg){ $data{"$x"}->{"$y"}++; $total++;}
	}
	print F "\\end{enumerate}\n";
}

foreach $key1 (%data){
	for ($i = $ystart; $i <= $yend; $i++){
		print F " $data{$key1}{\"$i\"}  "; 
	}
	print "\n";
}

print F "total = $total, t = $t\n";


print F "\\end{document}\n";
close F;

