#!perl.exe use Chatbot::Eliza; use strict; # # get mail as a whole # $|++; $/=undef; my $file = <>; $/="\n"; my ($headers,$mail)= split /\n\n/, $file,2; my @headers = split "\n", $headers; foreach (@headers ){ s/^To\s*\:/From\:/i && next; s/^From\s*\:/To\:/i && next; s/^Subject\s*: (.*?)/Subject: Re: $1/i; s/CC\s*:.*/CC:/i; } $headers=join "\n", @headers; # # paragraphs # my @paras = split /\n{2,}/, $mail; my $chatbot= new Chatbot::Eliza "your name here", "chatrex.txt"; my $resp=$headers."\n\nThank you for your mail! I am new to here, and do not have good english -- forgive :)"; my $reply; foreach (@paras) { $reply = $chatbot->transform( "$_"); $_= ">" . $_; $_= join "\n>",split ("\n", $_); $resp .= "$_\n\n$reply\n\n"; } print $resp;