Time: 1288034383 Author: kirsle Subject: Perl for RiveScript-Java! Avatar: RiveScript-Hazard.png Categories: General, Perl, Java Privacy: public IP: 72.37.252.50 NoEmote: 0 NoReply: 0 I've just checked in an update to the RiveScript-java code:

It supports Perl objects now!

So you can use your existing RiveScript Perl objects with the Java library now. Example:

+ encode * in md5
- "<star> in MD5 is: <call>md5 <star></call>

> object md5 perl
   my $rs = shift;

   use Digest::MD5 qw(md5_hex);
   return md5_hex(join(" ", @_));
< object

How does it work? There's a Perl script names "rsp4j.pl" that the Java library calls on. Java sends a JSON-encoded data structure to the Perl script containing the user's ID, message, user variables, and the source code to the Perl object. The Perl script loads the RiveScript Perl module and uses it to evaluate a response to the user. It then outputs a new JSON structure containing the user's reply and their new user variables (in case the Perl object called any setUservars methods on the $rs object).

The 0.02 version of rivescript-java has the Perl support. You can see its usage in the RSBot.java example script, or more generally here's all you need to do to get Perl support:

RiveScript rs = new RiveScript();
rs.setHandler("perl", new com.rivescript.lang.Perl(rs, "/path/to/rsp4j.pl");