#!/usr/bin/perl

use	strict;

my	$base_url = 'http://www.zukeran.org/shin/funifuni/';

my	%topicindex;

my	$yyyy;
my	$mm;
my	$dd;
my	$tt;
my	$current_month;
my	$current_day;
my	$current_topic;
my	$base_url;

open(NKF,"|/usr/bin/nkf");
select(NKF);


print <<"__EOF__";
<!DOCTYPE HTML PUBLIC "-//W3C//dtD HTML 4.01//EN">
<html lang="ja">
<head>
<link rev="MADE" href="mailto:shin\@opus.or.jp">
<link rel="INDEX" href="/shin/index.html">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-2022-JP">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" type="text/css" href="/shin/css/zu.css">
<title>shin's page / funifuni</title>
</head>
<body>
<!--#include file="header.html"-->

__EOF__

# htmlファイルをごりごり読む
# <h3><a name="27_01" href="../funifuni/200112.html#27_01">ルービックキューブ</a></h3>
while(<>){
	if (/^<h3><a name="([^"]+)" href="([^"]+)">([^<]+)<\/a><\/h3>$/) {
		$topicindex{$3} .= "$2\t";
	}
}

my	@topiclist;
my	@linklist;
my	$i;
my	$j;
my	$date;

foreach $i (sort keys %topicindex) {
	chop	$topicindex{$i};
	@topiclist = split(/[\t\n]+/,$topicindex{$i});
	print "<h2>$i</h2>\n";
	@linklist = ();
	foreach $j (reverse sort @topiclist) {
		$date = substr($j,0,4) . "/" . substr($j,4,2) . "/" . substr($j,12,2) . "-" . substr($j,15,2);
		push (@linklist,"<a href=\"$j\">$date</a>");
	}
	print join(',',@linklist);
	print "\n";
}

print <<"__EOF__";
<!--#include file="footer.html"-->
</body>
</html>
__EOF__

close NKF;

exit 0;
