use Net::Ping; # fill this array with your ips my @ips = map { "192.168.1." . $_ } ( 2 .. 254 ); my @ips_up; use constant { TIMEOUT => 5000, PORT => 7 }; my $p = Net::Ping->new( "syn", TIMEOUT() / 1000 ); $p->{port_num} = PORT; $p->ping($_) for (@ips); while ( my ( $host, $rtt, $ip ) = $p->ack ) { push @ips_up, $ip; } local $" = "\n"; print @ips_up;