sub metasearch { my $self = shift; # Note: could make dbs return array in array context # with 'wantarray' my @dbs = @{$self->dbs}; my @db_socks; foreach my $db (@dbs) { my $sock = $db->connect; send_nonblocking_query($sock); push @db_socks, $sock; } my $timeout_at = time() + $timeout_secs; while (@db_socks && time() < $timeout_at) { ..select on @db_socks, timing out at timeout_at ..handle a wakeup on a socket by reading the response } # error handling of remaining @db_socks }