use Getopt::Std;

getopt("dcs");

$dir=$opt_d;
$class=$opt_c;
$subject=$opt_s;


open(FIn,"<$dir/plan.csv");
print "<?xml version = '1.0' encoding = 'windows-1251' ?>\n";
print "<?xml-stylesheet href='../topics.xsl' type='text/xsl'?>\n<class>\n";
$i=1;
while(<FIn>) {
/(.*);(.*);(.*)/;
if ($1 eq "") {print "<theme file='par${i}.htm'><subject>$2</subject></theme>
\n";
$subj[$i]=$2;
$i++;
}
}
print "</class>";
$last=$i-1;
close(Fin);
for($i=1;$i<=$last;$i++){
    print STDERR "*";
    open(OFile,">$dir/par_top$i.htm");
	print OFile qq[<!DOCTYPE HTML PUBLIC "-/W3C/DTD HTML 4.0 Transitional/EN">
<HTML><HEAD><TITLE></TITLE>
<META content="text/html; charset=windows-1251" http-equiv=Content-Type><LINK 
href="assets/index2.css" rel=stylesheet type=text/css>
</HEAD>
<BODY>
<style>
table {font-family:Tahoma,Arial;font-size:9pt;}
a {color: #303070}
a:visited {color : #707090}
</style>
<table width="100%" cellpadding=5>
  <tr><td align="center" colspan=4>&nbsp;$subject &gt;&gt; $class класс &gt;&gt;  $subj[$i]</td><tr>
  <tr>];

if($i!=1) {
   print OFile qq[
						<td width="25%" align="left">&nbsp;<a href="par].($i-1).qq[.htm" target="_parent">&lt;&lt;&nbsp;предыдущая тема</a></td>
   ];
}
if($i!=$last) {
   print OFile qq[
						<td width="25%" align="right"><a href="par].($i+1).qq[.htm" target="_parent">следующая тема&nbsp;&gt;&gt;&nbsp;</a></td>
   ];
}
print OFile qq[
						<tr>
</table>

</body>
</html>];	
    close(OFile);
}