#!/usr/bin/perl require "cgi-lib.pl"; $YARFbase = "./"; $YARFweb = "./"; $method = $ENV{"REQUEST_METHOD"}; $type = $ENV{"CONTENT_TYPE"}; #if ($method ne "POST" || $type ne "application/x-www-form-urlencoded") { # &print_header ("Form method error"); # print "Index search querry must be a form with a POST method.\n"; # print "Just what the hell are you trying to pull, anyway?"; # print_footer(); # exit 0; #} ShowHeader("YARF! The Index"); &ReadParse(*input); #print "

", &PrintVariables (*input), "

"; # Debug output if (!$input{'submit'}) { ShowLevel(1); print qq^ The YARF index search engine allows you to search the table of contents of each YARF issue for key words or phrases. The database contains the following for each story, comic strip and picture and outputs in the following format:

issue number, page number, piece title, artist/writer name, type of piece

Be careful about entering too general of a search. You could get a lot of text back.
Search text:

This entry will output the table of contents for any one issue

Issue number:
^; ShowLevel(1); } # ---- Show table of content search results if ($input{'submit'} eq "Search") { ShowLevel(2); $query = $input{'query'}; print qq^

Your request: $query
^; print qq^
^; } print qq^
^; # -- Run throught the text index file. Match any lines. Change tabs to HTML formatting # -- Output with alternating white/grey backgounds $ix = 0; open (INDEXDB, "${YARFbase}indexsearch.txt"); while () { if (/$query/i) { $bg = "#FFFFFF"; $bg = "#E0E0E0" if $ix & 1; @ent = split (/\t/); $line0 = ""; $line1 = ""; $line2 = ""; $line3 = ""; $line4 = ""; print qq^$line0 $line1 $line2 $line3 $line4\n^; $ix++; } } close INDEXDB; print qq^
Issue Page Title Artist/Writer Type
$ent[0]$ent[1]$ent[2]$ent[3]$ent[4]
^; if ($ix == 0) { print qq^
Sorry. No matches to your search.
^; ShowLevel(2); } # --- Show the table of content of an issue if ($input{'submit'} eq "Show") { ShowLevel(2); $query = $input{'issue'}; $issue = $query; if ($issue < 10) { $issue = "0" . $issue; } if ($issue < 100) { $issue = "0" . $issue; } if ($query eq "S-1") { $issue = 'SP01'; } if ($query eq "18/19") { $issue = "018"; } print qq^
Issue # $query
^; $ix = 0; open (INDEXDB, "${YARFbase}indexsearch.txt"); while () { if (/^$query\t/i) { $bg = "#FFFFFF"; $bg = "#E0E0E0" if $ix & 1; s|\t|\n^; $ix++; } } close INDEXDB; print qq^
Issue Page Title Artist/Writer Type

|; s|\t|

|g; print qq^

$_
^; ShowLevel(2); } ShowFooter(); # ---- SUBROUTINES ---- sub ShowHeader { my $title = shift; print "Content-type: text/html\r\n\r\n"; print qq^ $title
Search Results
^; } sub ShowLevel { my $level = shift; print qq^
Main page ^; if ($level == 2) { print qq^ > Search Page^; } print qq^
^; } sub ShowFooter { print qq^Contents copyright YARF! The Journal of Applied Anthropomorphics\n^; print qq^^; }