@filesa=split (/\n/,`cat filenamelist.txt`);
print "<table style=\"width: 100%; text-align: center; margin-left: auto; margin-right: auto;\" border=\"0\" cellpadding=\"0\" cellspacing=\"2\">\n<tbody>\n";
print "<tr>\n";
foreach(@filesa) 
	{
	$filename = $_;
	$firstchar = substr($_, 0, 2);
	if ($firstchar <= 19) {
	    @firstcol[$#firstcol + 1] = $filename;
	}
	elsif ($firstchar <= 38) {
	    @secondcol[$#secondcol + 1] = $filename;
	}
	elsif ($firstchar <= 57) {
	    @thirdcol[$#thirdcol + 1] = $filename;
	}
	elsif ($firstchar <= 76) { 
	    @fourthcol[$#fourthcol + 1] = $filename;
	}
	else {
	    @fifthcol[$#fifthcol + 1] = $filename;
	}
}
for ($index = 0; $index <= 19; $index++) {
	$onum = substr(@firstcol[$index], 0, 2);
	$ofile = @firstcol[$index];
	print "<td><a href=\"http://projects.csail.mit.edu/films/aifilmsdynamicPage6.php?reel%23=$onum\">$ofile</a></td>\n";
	$tnum = substr(@secondcol[$index], 0, 2);
	$tfile = @secondcol[$index];
	print "<td><a href=\"http://projects.csail.mit.edu/films/aifilmsdynamicPage6.php?reel%23=$tnum\">$tfile</a></td>\n";
	$enum = substr(@thirdcol[$index], 0, 2);
	$efile = @thirdcol[$index];
	print "<td><a href=\"http://projects.csail.mit.edu/films/aifilmsdynamicPage6.php?reel%23=$enum\">$efile</a></td>\n";
	$fnum = substr(@fourthcol[$index], 0, 2);
	$ffile = @fourthcol[$index];
	print "<td><a href=\"http://projects.csail.mit.edu/films/aifilmsdynamicPage6.php?reel%23=$fnum\">$ffile</a></td>\n";
	$znum = substr(@fifthcol[$index], 0, 2);
	$zfile = @fifthcol[$index];
	print "<td><a href=\"http://projects.csail.mit.edu/films/aifilmsdynamicPage6.php?reel%23=$znum\">$zfile</a></td>\n";
       	print "</tr>\n<tr>\n";
}

print "</tbody>\n</table>\n";
