My Perl "career" got to the point where I'm trying to write an IRC bot (yeah, I'm 10 years behind). So far I've discovered Bot::BasicBot and it's pretty cool, but I'd like it to have a background thread that does things (for now, watch for new SVN revisions in our internal repo and announce them on IRC).

So I wrote a sub called watch_svn which is basically an infinite loop that prints messages on STDOUT and I'm calling it with a Bot::BasicBot::forkit method in the connected() routine of the bot.

Problem is I don't see anything printed by the bot (though it seems to be looping, i see /usr/bin/svn being spawned from time to time) and I can't figure out how to log stuff. The module has a log() subroutine and I tried passing a reference for the bot to watch_svn so I can do $self->log there, but it doesn't work.

Here's a condensed version of the script:

#!/usr/bin/perl use warnings; use strict; package Marvin; use base 'Bot::BasicBot'; my $channel = '#irctoys'; my $server = 'my.internal.server'; my $nick = 'marvin'; #### IRC event handlers overload #### sub connected { my $self = shift; $self->forkit({ channel => $channel, run => \&watch_svn, arguments => [ $self ], }); } #### my stuff #### sub watch_svn { my $self = shift; $self->log("watch_svn: Started main loop\n"); while (1) { $self->log("watch_svn: Inside main loop\n"); print "this should go on $channel\n"; sleep 60; } } #### actual bot #### package main; Marvin->new(nick => $nick, channels => [ $channel ], server => $server + ) ->run; exit;

I only get on stderr the messages from the bot stating that it joined the server and the channel, and nothing else. Help?


In reply to Bot::BasicBot forkit - help needed by rpetre

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.