chiron's Journal
http://use.perl.org/~chiron/journal/
chiron's use Perl Journalen-ususe Perl; is Copyright 1998-2006, Chris Nandor. Stories, comments, journals, and other submissions posted on use Perl; are Copyright their respective owners.2012-01-25T02:49:31+00:00pudgepudge@perl.orgTechnologyhourly11970-01-01T00:00+00:00chiron's Journalhttp://use.perl.org/images/topics/useperl.gif
http://use.perl.org/~chiron/journal/
Net::AIML
http://use.perl.org/~chiron/journal/31456?from=rss
I was messing around with the ALICE chatbot software, when i learnt about AIML, this is a way for users to easily create there own chatbot personalitys and ten have them interpreted through the ALICE Engine, i then wondered if this could be implemented in perl, turns out somemone has done this already <a href="http://www.virtualitas.net/perl/aiml/">'program v'</a>. However i found it hard to pick out the ALICE Engine as it was heavily integrated with other stuff.<br> <br>
Thats when i found out about Net::AIML a simple module that integrates into pandorabots, a server hosting ALICE bots, basically it was just sending POST requests to the webpage, nothing to fancy. Anyway for a laugh i built it into a ircbot, to see who would be fooled into believing it was a real person, several people got strung along for a while although the majority soon recognised the hidden AI. Here's the code for it: *Sorry about the single letter variables, i couldn't be bothered to name them*<blockquote><div><p> <tt> use Net::IRC;<br> use Net::AIML;<br> use strict;<br> use warnings;<br> <br> if (!@ARGV) {<br> <br> print "\nUSAGE: bot.pl [SERVER] [NICK] [CHAN]\nTo talk to the bot simply<nobr> <wbr></nobr>/msg [NICK] [MESSAGE]\nOr in the channel [NICK], [MESSAGE]. Within your irc client\n";<br> exit(0);<br> }<br> <br> my $b = Net::AIML->new(botid => 'ba30d497ce360e23');<br> my $i = new Net::IRC;<br> my $c = $i->newconn("Server", $ARGV[0], "Nick", $ARGV[1]);<br> my $x;<br> <br> $c->add_handler(376, \&o);<br> $c->add_handler('msg', \&m);<br> $c->add_handler('public', \&m);<br> $i->start;<br> <br> sub o {<br> (my $s = shift)->join($ARGV[2]);<br> $x = 1;<br> }<br> <br> sub m {<br> if ($x == 1) {<br> <br> my ($s, $e) = @_;<br> if ($e->{type} =~<nobr> <wbr></nobr>/public/ && $e->{args}[0] =~<nobr> <wbr></nobr>/^($ARGV[1]),<nobr> <wbr></nobr>/i or $e->{type} =~<nobr> <wbr></nobr>/msg/) {<br> <br> my $d = ($e->{type} =~<nobr> <wbr></nobr>/public/) ? $e->{to}[0] : $e->{nick};<br> my $r = $e->{args}[0];<br> $r =~ s/^($ARGV[1]),<nobr> <wbr></nobr>//i;<br> my $t = $b->tell($r)."\n";<br> <br> $t =~ s/^Alice<nobr> <wbr></nobr>://i;<br> $t =~ s/<\/?.+?>//g;<br> $s->privmsg($d, $t);<br> }<br> }<br> }</tt></p></div> </blockquote>chiron2006-10-31T11:47:43+00:00journalPerl Gui interface to Phillips GoGear
http://use.perl.org/~chiron/journal/31368?from=rss
About two years ago i bought a philips gogear mp3 player, it was ok, the main downside was lame software to load music on to it.<br> <br>
About a year ago it broke, i found it two weeks ago and through the magic of fist i fixed it ( apparently the hd needle gets stuck easily ).<br> <br>
I couldn't stand the software so i decided to write my own, not too hard i thought it uses sqlite, however i spent ages on working out the logic, in the end i ended up using a much better script from use.perl.org/~domm/ for the logic.<br> <br>
I then added the gui front end, making it easier to add & remove songs.<br> <br>
I spent some time then making it cross-platform as apparently activestate perl is happy with storing querys into an array, for use in a foreach ie:<br> <br>
<code>
my @ret = $main->getOpenFile(-multiple => 9999999, -filetypes => $types);<br>
foreach my $path (@ret) {</code> <br> <br>
However perl on linux isn't and i had to use:<br> <br>
<code>
my $ret = $main->getOpenFile(-multiple => 9999999, -filetypes => $types);<br>
foreach my $path (@$ret) {</code> <br> <br>
Hopefully it works ok, <a href="http://hxnet.co.uk/files/PSynGear.pl">here it is</a>. Thanks to Domm at http://use.perl.org/~domm/ for the original logic in his script <a href="http://svn.zsi.at:1000/repos/perl-scripts/trunk/gogear.pl">here</a>.
<br> <br>NOTE: God help me if someone actually opens more than 9999999 fileschiron2006-10-20T18:58:25+00:00journal