Here is the changed section of the code:
open(RESULTS2, "ping.txt") || die;
@results = <RESULTS2>;
open(RESULTS, ">ping.txt") || die;
$j = 1;
$a = 0; $f = 0;
while (@results) {
print $_;
if (m/Reply/) {
$output[$j] = $baseIP.$j.": Alive\n";
$j++; $a++;
} elsif (m/Request/) {
$output[$j] = $baseIP.$j.": Dead\n";
$j++; $f++;
} else {
#@output[$j] = $baseIP.$j.": Unusual Results, requires Manual Ping
+\n";
}
}
print RESULTS "Pinger Results:\n\n";
print RESULTS "Alive Nodes: $a\n";
print RESULTS "Dead Nodes: $f\n";
print RESULTS "\n\nDetailed Results:\n";
print RESULTS @output;
close(RESULTS);
close(RESULTS2);
|