Stories
Slash Boxes
Comments

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

chiron (7362)

chiron
  (email not shown publicly)
http://hxnet.co.uk/

Just so you know, I'm a 17 year old student residing in the UK, studying four subjects at A level, between partying (woot) and coursework im a half-assed perl hacker

Journal of chiron (7362)

Tuesday October 31, 2006
07:47 AM

Net::AIML

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 'program v'. However i found it hard to pick out the ALICE Engine as it was heavily integrated with other stuff.

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*

    use Net::IRC;
    use Net::AIML;
    use strict;
    use warnings;

    if (!@ARGV) {

        print "\nUSAGE: bot.pl [SERVER] [NICK] [CHAN]\nTo talk to the bot simply /msg [NICK] [MESSAGE]\nOr in the channel [NICK], [MESSAGE]. Within your irc client\n";
        exit(0);
    }

    my $b = Net::AIML->new(botid => 'ba30d497ce360e23');
    my $i = new Net::IRC;
    my $c = $i->newconn("Server", $ARGV[0], "Nick", $ARGV[1]);
    my $x;

    $c->add_handler(376, \&o);
    $c->add_handler('msg', \&m);
    $c->add_handler('public', \&m);
    $i->start;

    sub o {
        (my $s = shift)->join($ARGV[2]);
        $x = 1;
    }

    sub m {
        if ($x == 1) {

            my ($s, $e) = @_;
            if ($e->{type} =~ /public/ && $e->{args}[0] =~ /^($ARGV[1]), /i or $e->{type} =~ /msg/) {

                my $d = ($e->{type} =~ /public/) ? $e->{to}[0] : $e->{nick};
                my $r = $e->{args}[0];
                $r =~ s/^($ARGV[1]), //i;
                    my $t = $b->tell($r)."\n";

                $t =~ s/^Alice ://i;
                $t =~ s/<\/?.+?>//g;
                $s->privmsg($d, $t);
            }
        }
    }

Friday October 20, 2006
02:58 PM

Perl Gui interface to Phillips GoGear

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.

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 ).

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.

I then added the gui front end, making it easier to add & remove songs.

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:

my @ret = $main->getOpenFile(-multiple => 9999999, -filetypes => $types);
foreach my $path (@ret) {


However perl on linux isn't and i had to use:

my $ret = $main->getOpenFile(-multiple => 9999999, -filetypes => $types);
foreach my $path (@$ret) {


Hopefully it works ok, here it is. Thanks to Domm at http://use.perl.org/~domm/ for the original logic in his script here.

NOTE: God help me if someone actually opens more than 9999999 files