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

I am a newbie writing an IRC bot that lurks outside channels and dishes out relevant weather information by downloading and parsing XML from weatherroom.com. I recently set up a new Debian Linux box and moved my little bot onto it, set up perl 5.6.1 (the latest available in stable) and fired it up. (this script had previously worked fine on another, almost identical box) Yet instead of the "Connecting to server..." message I was expecting, I got this:

Can't connect to irc.aftran.com:6667!at /usr/local/share/perl/5.6.1/Net/IRC.pm line 192
Cannot connect to irc.aftran.com:6667: Bad file descriptor at ne0-2.pl line 32.

The first error was thrown by Net::IRC itself, the second by my script. So later on I upgraded to Debian testing, (with perl5.8.2), installed all my modules, and tried again. I got an identical error, save that it did not show "Bad file descriptor" for $!. The code that connects it to the server is:
#Connect to server my $irc = new Net::IRC; my $ircconn = $irc->newconn(Nick => $opts{'nick'}, Server => $opts{'server'}, Port => $opts{'port'}, Username => $opts{'identd'}, Ircname => $opts{'realname'}) or die "Cannot connect to $opts{server}\:$opts{'port' +}: $!"; print "Connecting to server...\n";
As this script has worked before, I'm completely stymied as to why it's not on a similar machine, and why upgrading to 5.8.2 made little or no difference. Any thoughts? thanks, -df

Replies are listed 'Best First'.
Re: Weird problems with Net::IRC
by revdiablo (Prior) on Feb 06, 2004 at 03:34 UTC

    I don't really have much to say about your problem directly, but I'm positive someone else is going to come around and recommend POE::Component::IRC instead of Net::IRC, so I'll just do that. PoCo::IRC is very nice, and as an added bonus you'll learn how to use POE. You might want to seriously consider switching. If you do, you'd probably want to check out the POE Cookbook, and in particular the IRC Bots section.

Re: Weird problems with Net::IRC
by Corion (Patriarch) on Feb 06, 2004 at 07:42 UTC

    "Upgrading Perl" is seldom the right choice, and if you upgrade and nothing changes chances are that you upgraded the wrong thing...

    My guess is that something with the network/routing/name resolution on the box is wrong. Did you try connecting to irc manually, through telnet and through a real irc client to debug the connection?

    I'm not sure if Perl 5.8.2 is the currently distributed version of Perl in Debian, but be aware that it is a bad idea to change your system Perl, especially for Debian, as many of their utilities rely on Perl and special Debian modules that they don't have on CPAN.

Re: Weird problems with Net::IRC
by diagonalfish (Initiate) on Feb 06, 2004 at 12:56 UTC
    The Perl upgrade was part of my switch to Debian Testing. Apt-get installed the new perl 5.8.2 itself, so it probably knew what it was doing. Probably. I know name resolution works because I tried connecting with irssi and it works fine, same with telnet. There's also an eggdrop running on the machine that's had no problems connecting and staying on the same server. As for POE, I may change over, one of my friends has been trying to get me to switch anyway. But.. any other ideas before I go rewrite it? :)
Re: Weird problems with Net::IRC
by halley (Prior) on Feb 06, 2004 at 18:24 UTC
    I'll reply at home with more specifics, but I think you need to add a mention of your own hostname or host address, now. The connection routine needs that information to ensure it's binding to the right IP stack, or something along those lines. Why Net::IRC needs this when no other apps needed to be changed, I have no idea. I ran into this problem over a year ago.

    --
    [ e d @ h a l l e y . c c ]