#!/usr/bin/perl # This simple script implements a Chatbot::Eliza # object in a cgi program. It uses the CGI.pm module # written by Lincoln Stein. # # Needless to say, you must have the CGI.pm module # installed and working properly with CGI scripts on # your Web server before you can try to run this script. # CGI.pm is not included with Eliza.pm. # # Information about CGI.pm is here: # http://www.genome.wi.mit.edu/ftp/pub/software/WWW/cgi_docs.html #use CGI; use CGI qw/:standard/; use Chatbot::Eliza; my $cgi = new CGI; my $chatbot = new Chatbot::Eliza "Yoda", "/home/sofia/public_html/askyoda/yoda.txt"; srand( time ^ ($$ + ($$ << 15)) ); # seed the random number generator $|=1; print $cgi->header; print $cgi->start_html(-title=>'BlueHarvest.net - Ask Yoda', -BGCOLOR=>'F9E8D2', -TEXT=>'817468'); open fp,"/home/sofia/public_html/askyoda/top.txt" || die "Error!"; while() { print $_; } close fp; open fp,"/home/sofia/public_html/web/t-top.txt" || die "Error!"; while() { print $_; } close fp; print $cgi->start_multipart_form; #print $cgi->h2('Ask Yoda'); # These lines contain the "Eliza" functionality. # User comments are passed through the module's transform # method, and the output is used to prompt the user # for futher input. if ( $cgi->param() ) { $prompt = $chatbot->transform( $cgi->param('Comment') ); } else { $prompt = $chatbot->transform('Hello'); } print $cgi->param('Comment',''); print $cgi->strong; print $cgi->font({size => '3', face => 'verdana', color =>'3366ff'}, 'Yoda:'); print $cgi->font({size => '3', face => 'verdana'}, $prompt); print $cgi->br; print $cgi->br; print $cgi->textarea( -name => 'Comment', -wrap => 'yes', -rows => 2, -columns => 50 ); print $cgi->br, $cgi->submit('Action','Tell Yoda'), $cgi->reset('Reset'); open fp,"/home/sofia/public_html/web/t-bot.txt" || die "Error!"; while() { print $_; } close fp; open fp,"/home/sofia/public_html/askyoda/bot.txt" || die "Error!"; while() { print $_; } close fp; print $cgi->endform; print $cgi->end_html; #print $cgi->br; #system "/home/sofia/public_html/askyoda/quote.cgi"; #print $cgi->br;