Wednesday, March 23, 2005

Chat with a Web Service Using Perl

Here is my Perl one liner that would let you chat with Dr. Eliza. Just paste this into your shell and check it out.

perl -MSOAP::Lite -e 'print SOAP::Lite->uri("")->proxy("")->Eliza($_)->result(), "\n" while (<STDIN>)'

You have got to love Perl for this!

Well, here's a short but not-so-sweet conversation I had with her. Obviously it was me who started the conversation.

Hi there! Are you a man or a woman?
I am a man
So what?
Why did you ask?
Do you think I care?
I think you do!

I am basically passing each line of text read from the standard-input to the Eliza Web-Service provided by D.Walker, using the SOAP::Lite module. So make sure you have the SOAP::Lite Perl module installed.

If you think you have had an interesting conversation with Eliza using my Perl one-liner, feel free to leave a snippet in the comments!

If you like chatting with code, you should also check out Bok Bok, the intelligent Yahoo! Messenger Bot.


Sid said...

Oops! I didn't realize that Blogger would consider the angled brackets in <STDIN> as making up an HTML tag. Fixed!

Sid said...

Me: I hate you!
Eliza: Cool, man. Me too. I am a she.

So, she hates herself.