#!/usr/bin/perl

use Storable;
use Data::Dumper;
use CGI;

my $indexfile = "./aquinasindex.storable";

my $index = retrieve($indexfile);

$par = CGI->new; 

$book    = $par->param('book');
$chapter = $par->param('chapter');

print "Content-type:text/html\n\n";
print "<html><head></head><body><h1>Hits for $book/$chapter</h1><p>";



my @hits = @{$index->{$book}{$chapter}};

foreach $hit(@hits) {
	my %h = %{$hit};
	print qq!<a href="$h{link}" target=_blank>$h{link}</a><br>---<br>\n!;
	#print Dumper %h;
	}

print "</body></html>"

#print "Book: $book, chapter: $chapter\n";
#print "\n--------\n";
#print Dumper $index->{$book}{$chapter};
#print "\n--------\n";
#print Dumper $index;
#print "\n--------\n";
#print Dumper @hits;