#!/usr/bin/perl -w

use Tie::File;
use CGI;
use Fcntl 'O_RDONLY';
require "info.pl";

$current = "fulltext.txt";
$query = new CGI;
$book = $query->param("book");
$verse = $query->param("verse");
$lineNum = $query->param("line");
$view = $query->param("view");

print "status:200 OK\ncontent-type: text/html\n\n";

tie @array,'Tie::File', $current, mode => 'O_RDONLY' or die "Unable to tie file in showtext\n";

$found = 0;
($a,$b) = split ':', $filePos{$book};

if($view){
	for $k ($a..$b){
		if($k == $lineNum){
			print "<b><br>$array[$k]</br></b>";
		}
		else{
			print "<br>$array[$k]</br>";
		}
	}
}
else{
	for $i ($a..$b){
		if($array[$i] =~ m/\D$verse\D/){
			print "<br> $array[$i] </br>";
			$found = 1;
		}
	}
	if(!$found){
		print "<br> There were 0 hits on your search for the verse $book $verse</br>";
	}
}#end else

