in reply to perl bot problems
There are several problems in your code. I'll list them below. But first, why are you not using Net::IRC? If you want to reinvent the wheel, then why are you not using IO::Socket::INET? Why are you doing all the dirty work yourself?
Here are the things that are causing the problems:
if ($inchar eq "\n") # $inchar is one char long
{
chop $inline; # remove it
return $inline; # return empty.
}
Now back to using IO::Socket::INET, the above code can be shortened to:
Hope this helps,,,use IO::Socket; my $server = 'irc.openprojects.net'; my $port = 6667; my $nick = 'aziz'; my $name = 'Abdulaziz Ghuloum'; my $sock = IO::Socket::INET->new( PeerAddr => $server, PeerPort => $port) or die "Cannot connect: $!\n"; print $sock "USER $nick buf buf :$name\r\n"; print $sock "NICK $nick\r\n"; while(<$sock>){ print; my ($pingchk,$rest)=split(/ /,$_,2); if ($pingchk eq 'PING') { print $sock "PONG $rest\r\n"; } }
Aziz,,,
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: perl bot problems
by Anonymous Monk on Aug 10, 2001 at 23:58 UTC | |
by abstracts (Hermit) on Aug 11, 2001 at 00:11 UTC |