Never be lonely again

brian_d_foy on 2002-11-19T04:25:50

Now I have someone to talk to in my hotel room. The Tie::IO::Speak stuff comes from my previous Mac::Speech thingy.

use Chatbot::Eliza;
use Tie::FileHandle::Multiplex;

$mybot = Chatbot::Eliza->new( ); srand( time() ^ ($$ + ($$ << 15)) );

tie *SPEAK, 'Tie::IO::Speak'; tie *OUT, 'Tie::FileHandle::MultiPlex', *STDOUT, *SPEAK;

print OUT "$mybot->{initial}[ 0 ]\n";

$\ = "\n";

while( <> ) { chomp; last if $mybot->_testquit( $_ );

print OUT $mybot->transform( $_ ); }

print OUT "$mybot->{final}[ 0 ]";