deadpickle has asked for the wisdom of the Perl Monks concerning the following question:
sub chat{ $|++; my $parser = Parse::IRC->new( public => 1 ); my %dispatch = ( 'ping' => \&irc_ping, '001' => \&irc_001, 'public +' => \&irc_public, 'quit' => \&irc_quit, 'join' => \&irc_join, '353' +=> \&irc_353); while(1){ if ( $die == 1 ){ goto END }; if ( $chat_start == 1 ) { $post = 1; $sock = new IO::Socket::INET(PeerAddr => $irc, PeerPort => 6667, Proto => 'tcp') or die "Can't connect\n"; # Log on to the server. print $sock "NICK $nick\r\n"; print $sock "USER $login 8 * :CoCoNUE Member $nick\r\n"; # Keep reading lines from the server. #for (;;){ #print "in\n"; while (my $input = <$sock>) { #print "1\n"; $input =~ s/\r\n//g; my $hashref = $parser->parse( $input ); #print "2\n"; SWITCH: { #print "3\n"; my $type = lc $hashref->{command}; my @args; push @args, $hashref->{prefix} if $hashref->{p +refix}; push @args, @{ $hashref->{params} }; if ( defined $dispatch{$type} ) { #print "4\n"; $dispatch{$type}->(@args); last SWITCH; } print STDOUT join( ' ', "irc_$type:", @args ), + "\n"; #print "5\n"; } #print "6\n"; #print "die = $die\n"; if ( $die == 1 ){print "Ending\n"; goto END }; if($chat_start == 0){ last}; } #print "out\n"; #if ( $die == 1 ){print "Ending\n"; goto END }; #if($chat_start == 0){ last}; #} close $sock; }else { sleep 1 } } END: }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Joining a Thread in w While loop
by pc88mxer (Vicar) on Mar 05, 2008 at 04:52 UTC | |
by deadpickle (Pilgrim) on Mar 05, 2008 at 15:31 UTC | |
by pc88mxer (Vicar) on Mar 05, 2008 at 16:20 UTC | |
by deadpickle (Pilgrim) on Mar 05, 2008 at 19:57 UTC | |
by zentara (Cardinal) on Mar 05, 2008 at 20:23 UTC | |
|