#!/usr/bin/perl use strict; use warnings; use Net::Ping; my @host_array = ("127.0.0.1", "10.0.0.10"); my $p = Net::Ping->new("tcp"); # $p->bind($my_addr); # Specify source interface of pings foreach my $host (@host_array) { print "$host is "; print "NOT " unless $p->ping($host, 2); print "reachable.\n"; sleep(1); } $p->close(); __END__ $ perl test.pl 127.0.0.1 is reachable. 10.0.0.10 is NOT reachable.