http://qs321.pair.com?node_id=472063

dReKurCe has asked for the wisdom of the Perl Monks concerning the following question:

Greetings Monks:

I am new to object orientation and am learning by example. I have read the Net::IRC documentation and discovered along the way that POE provides a better solution. The following code is from the module documentation but alas I am missing the plot. The following code generates:
Can't call method "post" on an undefined value at POEirc line 14. POE::Kernel's run() method was never called.

Any advice on how to tweak this could enrich my knowledge of OO . thanks.
use POE::Component::IRC; my ($irc)=POE::Component::IRC->spawn()or die; $irc->yield ('register' => 'all'); $irc->yield('connect', { Nick => 'n3u7bot', Server => 'irc.2600.net', Port => 6667, Username => 'HAL', Ircname => 'darkphiber', } ); $kernal->post( 'my client ', 'join', '#2600tn' );

Replies are listed 'Best First'.
Re: Using POE::Component::IRC
by johnnywang (Priest) on Jul 03, 2005 at 22:00 UTC
Re: Using POE::Component::IRC
by bart (Canon) on Jul 03, 2005 at 20:30 UTC
    Nowhere at all do you assign a value to $kernal. Of course does it contain an undefined value.

    update: I checked the example code in POE::Component::IRC. their code talks about "$kernel". Perhaps you just have a typo?

    I am assuming use of that module automatically uses (and assigns to) the (global) variable $kernel. I'm not sure about that.

    Nope, I doubt it. I think you actually have to combine this module with plain POE. Bad module documenters. This is not clear at all.

Re: Using POE::Component::IRC
by Anonymous Monk on Jul 04, 2005 at 01:06 UTC
    Net::IRC is much easier to install, understand and use. It takes less memory and isn't prone to spawn a hundred zombies if you make a mistake. I'm curious about why POE provides a better solution? Thanks.
      This is not a direct answer to your question, but I did find some problems with Net::IRC.

      I recently found that SlashNET presumes that a client is disconnected if it does not send PING messages at a regular pace. Net::IRC doesn't, and trying to fix it using do_one_loop made me discover that this function should be called from a package when working with use warnings;. I also had to hack the module to add support for the PONG answer message.

      Flavio
      perl -ple'$_=reverse' <<<ti.xittelop@oivalf

      Don't fool yourself.