#!/usr/bin/perl

use Net::Ping;

exit (ping("10.0.0.1",$ARGV[0]));

# pings from the interface passed
sub ping {
   local ($from, $to)=@_;

   my $p=Net::Ping->new("icmp");
   $p->bind($from);
   local $number_times=0;
   while($number_times<5) {
      print "\nPinging from $from to $to... $number_times";
      if($p->ping($to)) {
         return(0);
      }
      $number_times++;
   }
   return(1);
}
