Listing 3.
Scripting a dialogue between chatbots.
John Nolan

Chatbot::Eliza
The Perl Journal, Spring 1998
  Listing 3: Scripting a dialogue between chatbots.


use Chatbot::Eliza



my ($harry, $sally, $he_says, $she_says);

$sally = new Chatbot::Eliza "Sally"; 

$harry = new Chatbot::Eliza "Harry";



$he_says = "I am sad.";



# Seed the random number generator.

srand( time ^ ($$ + ($$ << 15)) );



print $harry->name, ": $he_says \n";



while (1) { 

    $she_says = $sally->transform( $he_says ); 

    print $sally->name, ": $she_says \n";



    $he_says = $harry->transform( $she_says ); 

    print $harry->name, ": $he_says \n";