# Create a list of all possible IP addresses within subnet open(ALLIP, ">allip.list") || die "Unable to create file: allip.list\n"; for ($i=0; $i<=20; $i++) { print ALLIP "$ip_subnet.$i\n"; } open(ALLIP, "allip.list") || die "Unable to open file: allip.list\n"; open(PINGALLIP, ">pingallip.list") || die "Unable to open file: pingallip.list"; while () { system("ping $_ >pingallip.list") && "Unable to create file: pingallip.l ist"; chomp; } open(OUTPUT, ">output.list"); open(PINGALLIP, "pingallip.list") || die "Unable to open file: pingallip.list"; my $line = 0; while () { chomp; #my $line = 0; #while () { #chomp; if ($_ eq~ m/is alive/) { $line++; last; } } close(ALLIP); if ($line) { print OUTPUT "$_\n"; } else { print "ERROR\n"; }