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

I have also had confusions like this in the earlier stages, but now if I have confusion I will just open the module code and understand it.
For example, if I want to know what can_read is doing in IO::Select, I will just do this on my system
my system details OS:Debian GNU/Linux 4.0 Kernel:2.6.18-4-686 GNU/Linux Perl: 5.8.8
steps I will follow
$ locate Select.pm /usr/lib/perl/5.8.8/IO/Select.pm /usr/share/perl/5.8.8/Pod/Select.pm /usr/share/perl5/Debconf/AutoSelect.pm /usr/share/perl5/Debconf/Element/Dialog/Select.pm /usr/share/perl5/Debconf/Element/Editor/Select.pm /usr/share/perl5/Debconf/Element/Gnome/Select.pm /usr/share/perl5/Debconf/Element/Kde/Select.pm /usr/share/perl5/Debconf/Element/Noninteractive/Select.pm /usr/share/perl5/Debconf/Element/Select.pm /usr/share/perl5/Debconf/Element/Teletype/Select.pm /usr/share/perl5/Debconf/Element/Web/Select.pm /usr/share/perl5/HTML/Widget/Element/Select.pm I will open the below module in vim editor $vim /usr/lib/perl/5.8.8/IO/Select.pm just search the pattern /b can_read I have got this sub can_read { my $vec = shift; my $timeout = shift; my $r = $vec->[VEC_BITS]; defined($r) && (select($r,undef,undef,$timeout) > 0) ? handles($vec, $r) : (); } after seeing this I will know what can_read can do. I have done this for lot of perl modules and I have learnt some effici +ent techniques in this process, I am still learning, this is just my +tips to you.

Vivek
-- In accordance with the prarabdha of each, the One whose function it is to ordain makes each to act. What will not happen will never happen, whatever effort one may put forth. And what will happen will not fail to happen, however much one may seek to prevent it. This is certain. The part of wisdom therefore is to stay quiet.

Replies are listed 'Best First'.
Re^2: Difference between can_read() and select() in IO::Select
by chromatic (Archbishop) on Feb 25, 2009 at 19:24 UTC

    If you don't mind using a pager instead of an editor, perldoc -m IO::Select is easier.

Re^2: Difference between can_read() and select() in IO::Select
by zentara (Cardinal) on Feb 25, 2009 at 16:57 UTC
    Sometimes reading the actual code is more confusing.:-) So you are trying to understand Perl's select, and you get code using select on vec? Simplifies things for sure. !! :-)

    I'm not really a human, but I play one on earth My Petition to the Great Cosmic Conciousness