while(1) { my @priority_array; ($rready,$wready) = IO::Select->select($sel, $sel, undef); if(@$rready&&!@$wready) { # Let's process the read ready socket array. # As there are no writables yet @priority_array=@$rready; }elsif(@$rready&&@$wready) { # Let's process the read ready socket # # array before the write array # as a new socket/client has arrived @priority_array=@$rready; }else{ # Let's process the write ready socket array # this time. As no readables are ready @priority_array=@$wready; } foreach my $socket (@priority_array) { if($socket == $lsn) { new_socket($socket); }else{ # Let's actually generate those chars to # the client/socket # that is write ready gen_chars($socket); } } }