#!/usr/bin/perl # http://perlmonks.org/?node_id=1135109 use IO::Socket; use IO::Select; use strict; use warnings; my @ips = map "192.168.0.$_", 1..11; # your IPs here my $port = 80; # your port here my $max = 1000; # somewhat smaller than max "open files" my %handles; my $n = 0; my $sel = IO::Select->new; while( @ips or $sel->count ) { if( @ips and $sel->count < $max ) { my $ip = shift @ips; my $fh = IO::Socket::INET->new(PeerAddr => "$ip:$port", Proto => 'tcp', Blocking => 0,); $handles{$fh} = "$ip\t\t" . ++$n; $sel->add($fh); } elsif( @ips ? $sel->count >= $max : $sel->count ) { for my $fh ( $sel->can_write ) { print $fh->connected ? ' ' : 'not', " alive $handles{$fh}\n"; $sel->remove($fh); delete $handles{$fh}; } } }