Dear Monks,

I'm using IO::Select in order to switch between different clients connected to the same server program. At first, I used a sample code to understand how IO::Select works. That code uses the select() method in order to find the clients that have produced some output, like this:

$read_set = new IO::Select(); # create handle set for reading $read_set->add($socket); # add the main socket to the set # Get a set of readable handles (blocks until at least one handle is r +eady) my ($rh_set) = IO::Select->select($read_set, undef, undef, 0);

Now, after reading the module's documentation, I'm trying to understand what's the difference between using can_read() and select(). Can the last line in the above extract be written as  my @rh_set = $read_set->can_read(); ?

I can see that one method is static whole the other is not, and that one returns references to arrays, while the second returns one array - but are there any differences in the results themselves? Is one of them somehow "better" to use than the other?

Thanks a lot!


In reply to Difference between can_read() and select() in IO::Select by anna_black

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.