while (1) { my @ready; @ready = $Select->can_read(1); foreach $fh (@ready) { my $fn = $fh->fileno; unless ($_ = $fh->getline()) { $Select->remove($fh); next; } # work with $_ here } }