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

Can the last line in the above extract be written as my @rh_set = $read_set->can_read();?
Yes.

but are there any differences in the results themselves? Is one of them somehow "better" to use than the other?
No difference in results.

Replies are listed 'Best First'.
Re^2: Difference between can_read() and select() in IO::Select
by ikegami (Patriarch) on Feb 25, 2009 at 15:41 UTC

    No, they're not the same.

    my ($rh_set) = IO::Select->select($read_set, undef, undef, 0);
    is actually equivalent to
    my @rh_set = $read_set->can_read(0);
    These are non-blocking.

    my @rh_set = $read_set->can_read();
    and
    my @rh_set = $read_set->can_read(undef);
    block just like
    my ($rh_set) = IO::Select->select($read_set, undef, undef);
    and
    my ($rh_set) = IO::Select->select($read_set, undef, undef, undef);

    To the OP, can_read is just a thin wrapper around IO::Select::select that saves you from specifying undefs and dealing with the more complex return value.