Use IO::Select->select
:
select ( READ, WRITE, EXCEPTION [, TIMEOUT ] )
select
is a static method, that is you call it with the package name like new
. READ
, WRITE
and EXCEPTION
are either undef
or IO::Select
objects. TIMEOUT
is optional and has the same effect as for the core select call.
The result will be an array of 3 elements, each a reference to an array which will hold the handles that are ready for reading, writing and have exceptions respectively. Upon error an empty list is returned.
For example:
my $rsel = IO::Select->new($rfh);
my $wsel = IO::Select->new($wfh);
my $esel = IO::Select->new($rfh, $wfh);
my @ready = IO::Select->select($rsel, $wsel, $esel, undef);