#!/usr/local/bin/perl

$NumLigne = 0;
$NomFichier = $ARGV[0];
open(HTMLFIC,">$NomFichier.html");
open(HTMLIND,">$NomFichier.ind.html");
while(<>)
	{
	chop;
	$NumLigne++;
	$ligne = $_;
	s/[\(\)\[\]"]//g;	# nettoyage
	s/,/ ,/g;		# on isole les ,
	@TableauMot = split(/[' \t]+/);
	print HTMLFIC "<A NAME=\"$NumLigne\">";
	foreach $Mot (@TableauMot)
		{
		print HTMLFIC "($Numligne)<A HREF=\"$NomFichier.ind.html#$Mot\">$Mot</A> "; 
		unless ($IndexMot{$Mot} =~ /$NumLigne /)
			{
			$IndexMot{$Mot}=$IndexMot{$Mot}.$NumLigne." ";
			}
		}
	print HTMLFIC "</A><P><P>\n";
	}
	
close(HTMLFIC);
@IndexMotTri = sort keys %IndexMot;
foreach (@IndexMotTri)
	{
	@NumIndex = split(/ /,$IndexMot{$_});
	print HTMLIND "<B><A NAME=\"$_\">$_</A></B> ";
	foreach $Num (@NumIndex)
		{
		print HTMLIND "    <A HREF=\"$NomFichier.html#$Num\">$Num</A>\n";
		}
	print HTMLIND "<BR>";
	}
