dear perl monks.

i am somewhat of a perl beginner, and over the last few months have grown to love the language. As an attempt to learn to use various modules, i have written the following perl script. It is the beginnings of a very basic irc client.

the whole script and the configuration file

########## #this is the bit that bugs out, afaik ########## #enter select group read wait loop my @ready_sockets; while (@ready_sockets = $select_group->can_read) { #for each socket..... foreach my $sock (@ready_sockets) { #pull data from the socket my $data = <$sock>; #if the data is null, socket is closed if (!($data)) { print "socket closed\n" if $debug; #pull it out of the select group $select_group->remove($sock); $sock->close; return; } print "socket replied: $data" if $debug; if (substr($data,0,4) eq "PING") { print "pong" . substr($data,4); print $sock "PONG" . substr($data,4); } } }

However, the script seems to have a problem that i cannot solve. when connecting to the irc server, the script correctly receives the first few lines, and then seems to ignore the data on the socket for a random amount of time. Oddly, it always pauses at the same point on each server, but it is a different point on each server. this leads the connection to time out.

it would appear that after reading the first few lines, the $select_group->can_read is not recognising data ready for reading on the socket. I do not know why.

so far i have tried the following to solve this problem:-

could anyone shed any light on this? i have been working on this all day and can see no reason at all why it should behave in this way. any help would be appreciated.

thankyou in advance.


In reply to select appears to ignore pending data on socket. by Zidane

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.