Hello all. I'm having trouble with a script I'm running on my linux box. It's an IRC bot that was working when I first wrote it, but now that I've rebooted my computer and tried to run it again, it doesn't seem to work, and it issues my these two errors:

Can't connect to irc.whatever.net:6667! at /usr/lib/perl5/site_perl/Net/IRC.pm line 192

Can't call method "add_handler" on unblessed reference at ./bot line 75.

Here is what my code looks like:
#!/usr/bin/perl use Net::IRC; use strict; # create the IRC object my $irc = new Net::IRC; # Create a connection object. You can have more than one "connection" +per # IRC object, but we'll just be working with one. my $conn = $irc->newconn( Server => shift || 'irc.whatever.net', Port => shift || '6667', Nick => 'Bot', Ircname => 'Bot', Username => 'Bot'); # We're going to add this to the conn hash so we know what channel we # want to operate in. $conn->{channel} = shift || '#mychannel'; sub on_connect { # shift in our connection object that is passed automatically my $conn = shift; # when we connect, join our channel and greet it $conn->join($conn->{channel}); $conn->privmsg($conn->{channel}, 'Hello everyone!'); $conn->{connected} = 1; } sub on_join { # get our connection object and the event object, which is passed # with this event automatically my ($conn, $event) = @_; # this is the nick that just joined my $nick = $event->{nick}; # say hello to the nick in public $conn->privmsg($conn->{channel}, "Hello, $nick!"); } sub on_part { # pretty much the same as above my ($conn, $event) = @_; my $nick = $event->{nick}; $conn->privmsg($conn->{channel}, "Goodbye, $nick!"); } sub on_public { my($conn, $event) = @_; my $text = $event->{args}[0]; if ($text eq "\U$text") { if (length $text > 6) { my $name_text = $event->{nick}; $conn->privmsg($event->{to}[0], "$name_text: No need to yell. Switch t +o lowercase and be happy. =)"); } } sub on_msg { my($conn, $event) = @_; $conn->privmsg($event->{nick}, "I, don't appreciate being /msg'd."); } # add event handlers for join and part events $conn->add_handler('join', \&on_join); $conn->add_handler('part', \&on_part); $conn->add_handler('public', \&on_public); $conn->add_handler('msg', \&on_msg); # The end of MOTD (message of the day), numbered 376 signifies we've c +onnect $conn->add_handler('376', \&on_connect); # start IRC $irc->start();
_______________________

I entered irc.whatever.net for the server, because I've tried to connect it to multiple servers and it won't connect to any of them. I would think that this is simply a problem with my code, because it usually is =), but this same script was working before i rebooted my computer. Any help on this subject would be greatly appreciated, as I'm pulling my hair out over it. =)

Thanks a lot

Edit by myocom: (fixed code tags)

In reply to Net::IRC problem by Anonymous Monk

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.