#!/usr/bin/perl -Tw
######################################################
######################################################
## Michelle Cooper, Matt Dever, Kevin Miller, Jr. ##
## mcooper@indiana.edu ##
## mdever@indiana.edu ##
## kevmille@indiana.edu ##
## L548 ACARI Project ##
## modified on August 1, 2003 by Kevin Miller, Jr. ##
######################################################
######################################################
#------------------------------------------------
# program serves as a search tool to assist visitors
# to the ACARI website locate .pdf documents fitting
# their search criteria.
#------------------------------------------------
use CGI qw(:standard -debug);
use CGI::Carp qw(fatalsToBrowser);
#--------------
# configuration
#--------------
$update = 'August 1, 2003,'; # Last Update Date for web site
$updateby = 'Kevin Miller, Jr.'; # Person who updated web site
# define/assign variables
$keyword = param("keyword");
#$title = param("title");
#$author = param("author");
# opens directory with .pdf files in it, and creates an array for searching
opendir(IND,".") || die "can't read .\n";
@files= readdir(IND);
closedir(IND);
&htmlopen; # starts the html output page(s)
&htmlbody1; # generates the body of the page, including links to articles
&htmlfin; # ends the HTML output page(s)
sub htmlopen
{
print header();
print "";
print "
";
print " Welcome to M. Nazif Shahrani's "Afghanistan and Central Asia Resource Information" Web site";
print " ";
print " ";
print " ";
}
sub htmlbody1 # generates the html to place links in the lower left portion of the ACARI page.
# calls sub links, which searches keywords and generates links
{
print<
//-->
 |
Afghanistan and Central Asia Research Information
Indiana University, Bloomington, Indiana
URL: http://www.indiana.edu/~afghan
|
EOP
# ## Here begins the cell in which the results of the search will appear
print "";
print " ";
print "Search Results";
print "Keyword = $keyword ";
&links; # calls sub links, which searches for keywords and generates links
# to .pdf documents in the ACARI webpage
$i--; # counts links generated,
print "Total Results = $i"; #and prints number
print<
Search Publications
|
EOP
# ## here ends the cell in which the links appear
print<
|
| Last Updated on $update by $updateby |
EOP
} # end sub body1
#------------------------------------------------
# find keywords, generate links for display to user
# sub routine K. Yang
sub links {
$i=1;
foreach $inf(@files) {
next if ($inf !~/\.pdf$/i);
open(IN,$inf) || die "can't read $inf";
$inf2= $inf;
while () {
if (m!(.*($keyword).*)!i) # ||
# (m!(.*($title).*)!i) || # advanced search features
# (m!(.*($author).*)!i) # not used for this project
{
print "$i. "; # create link
$inf2 =~ s|_| |g; # chop extraeous characters from
$inf2 =~ s|\.pdf$||; # file names
print "$inf2"; # link appears as file name (title)
$i++;
}
}
}
} # end sublinks
sub htmlfin
{
print "