A good idea. In shorthand:
#-------------------Connect to IRC Server------------------- sub connecting { # Connect to the IRC server. $sock = new IO::Socket::INET( PeerAddr => $irc, PeerPort => 6667, Proto => 'tcp', ) or die "Can't connect\n"; print $sock "NICK $nick\r\n"; print $sock "USER $login 8 * :CoCoNUE Member $nick\r\n"; $sel->add($sock); ################################################# #Timeout my $timer_chat = Glib::Timeout->add(1, \&incoming_data); #################################################\ return 1; } #-------------------Watch for IRC Inputs------------------- sub incoming_data { if ($sel->can_read(1)){ my $input = <$sock>; $input =~ s/\r\n//g; my $hashref = $parser->parse( $input ); SWITCH: { my $type = lc $hashref->{command}; my @args; push @args, $hashref->{prefix} if $hashref->{prefix}; push @args, @{ $hashref->{params} }; if ( defined $dispatch{$type} ) { $dispatch{$type}->(@args); last SWITCH; } print STDOUT join( ' ', "irc_$type:", @args ), "\n"; } } return 1; }
Now the only problem is that the GTK2 window stops responding. I think its caused by the my $input = <$sock> having nothing to read and it just makes the GTK2 program angry. Is there a way to avoid this other than adding a watch or any other crazy GTK2 dispatcher? Thanks for the help everyone.
Update: should IO::Select be used? I have been barking up that tree with not much success either. I added the IO::Select to the loop and the program is now responding but it is very sluggish which is bad. any ideas?

In reply to Re^6: Joining a Thread in w While loop by deadpickle
in thread Joining a Thread in w While loop by deadpickle

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.