Listing 1
     
#! /bin/perl
     
#$File = "/etc/pinglist";
     
open( FILE, $File ) || die "Cannot open $File";
     
while ( <FILE> ) {
     
 next if /^#/;
 next if /^127\./;
 chop($Host = $_);
     
 $Res = `ping -c 3 $_`;
     
 if ( $Res =~ /3 pac\w* trans\w*, 3 pac\w* rec\w*, 0% pac\w* loss/ ){
  print "$Host OK\n";
  next;
 }
     
 print "$Host FAILED!!!\n", $Res;
}

