[Home]MakeMasterList

Morsulus Home Page | RecentChanges | Preferences

No diff available--this is the first major revision. (no other diffs)
This expects to be fed a list of file names. The files are the HTML file that holds all the items for a given person. It expects that the title tag in that file will be the name on the file.
#!/usr/bin/perl
use strict;
use warnings;

use Carp;
use IO::File;

print <<HEAD;
<HTML>
<HEAD>
<TITLE>Consolidated Archive Listing</TITLE>
</HEAD>
<BODY><H1>Consolidated Archive Listing</H1>
<HR>
<P>
HEAD

my %names;

while (<>)
{
	chomp;
	my $name = get_title($_);
	push @{$names{$name}}, "<a href = \"$_\">$name</a><br>\n";
}

foreach my $name (sort keys %names)
{
	print @{$names{$name}};
}

print <<TAIL;
<HR>
</BODY>
</HTML>
TAIL

sub get_title
{
	my $file = shift;
	my $fh = IO::File->new($file) or warn "Can't open '$file': $!";
	return $file unless $fh;
	my $contents;
	{
		local $/;
		$contents = <$fh>;
	}
	if ($contents =~ m:<title>(.+)</title>:i)
	{
		return $1;
	}
	else
	{
		return $file;
	}
}

Morsulus Home Page | RecentChanges | Preferences
This page is read-only | View other revisions
Last edited March 23, 2008 10:47 pm by Herveus (diff)
Search: