Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Monday November 18, 2002
11:25 PM

Never be lonely again

[ #9013 ]

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 ]";