my @sockets; foreach ( @hosts ) { push @sockets, IO::Socket->new(blah blah blah); } while ( 1 ) { foreach ( @sockets ) { if ( $_->exists && $_->is_open) { do_stuff($_); } } }