#!/usr/bin/perl -w
sub Get_Title {
my $file = shift;
unless(-f $file) { return("NO INDEX"); }
local *HTML;
local *_;
open(HTML,"<$file");
while(){
if(/
(.*)<\/title>/i) {
return $1;
}
}
return "Untitled";
}
my $dir ="/usr/local/apache/htdocs/projects";
my $url ="http://mattwork.potsdam.edu/projects";
opendir(PRJD, $dir);
my @dirs = readdir PRJD;
closedir(PRJD);
print "Content-Type: text/html\n\n";
print "Project Index Page\n";
print "Project Index Page
\n";
print "\n";
for(@dirs) {
if(/^\./) { next; }
unless(-d "$dir/$_") { next; }
my $file = "$dir/$_/index.html";
my $title = Get_Title($file);
print "- $_: $title\n";
}
print "
";