#!/usr/bin/perl -d use Getopt::Long; use DB_File; $dbmfile = '/export/home/apache/htdocs/ncsa/riverweb/notebook/notebook1/database/riverweb.dbm'; tie %hash, DB_File, $dbmfile; # open database, to be accessed #print "Debug: Error: $!\n"; &PrintQuestions; print "\n\nPlease type in a question index number, or q to quit:\n"; while (){ chop; if ($_ eq 'd'){ &DisplayQuestionsArray; } elsif ($_ eq 'q'){ exit; } else{ print "User responses for location $_:\n\n"; ($parsedinfo[0], $parsedinfo[1], $parsedinfo[2], $parsedinfo[3], $keywords, $parsedinfo[4]) = split(/\|/, $hash{$_}); $link = $_; @formkeys = split(/:/, $keywords); foreach $word (@formkeys){ print "$word\n"; } print "\nQuestion: $parsedinfo[4]\n\n"; } while (($key, $val) = each %hash){ ($parsedinfo[0], $parsedinfo[1], $parsedinfo[2], $parsedinfo[3], $keywords, $parsedinfo[4]) = split(/\|/, $val); if ($_ eq 'q'){ exit; } #print "DEBUG:$parsedinfo[3] eq $link?\n"; if ($parsedinfo[3] eq $link){ print "\n"; if ($parsedinfo[1] eq '3'){ print "User: $parsedinfo[2]\nResponse: $parsedinfo[4]\n\n"; } } } print "\n\nPlease type in a question index number, d for index, or q to quit:\n"; } untie %hash; sub DisplayQuestionsArray{ $i = 0; while ($i <= $#questions){ print "$questions[$i]...\n"; $i++; } print "\n\n\a Please type in a question index number, or q to quit:\n"; } sub PrintQuestions{ print "Here'is a list of questions for the riverweb database\n"; $i = 1; #print "Debug: PQustns \n"; while (($key, $val) = each %hash){ # pre process the entry for testing ($parsedinfo[0], $parsedinfo[1], $parsedinfo[2], $parsedinfo[3], $keywords, $parsedinfo[4]) = split(/\|/, $val); #print "Debug: $parsedinfo[1]\n"; if ($parsedinfo[1] eq 1){ $i++; $crop = (substr $parsedinfo[4], 0, 70); $question = ($parsedinfo[0] . ': ' . $crop); print "$question...\n"; push @questions, $question; } } }