in reply to Pinging multiple hosts
our @hosts = qw /www.yahoo.com www.cpan.org www.perlmonks.org bob.net/; our %host_state = (); #our @alive = `fping -a @hosts`; # 2>/dev/null keeps us from get error messages for fping our @alive = `fping -a @hosts 2> /dev/null`; chomp @alive; for my $host (@alive) { $host_state{$host} = 1; } for my $host (@hosts) { print $host, " is "; print $host_state{$host} ? "alive" : "dead"; print "\n"; }
|
|---|