in reply to Checking ADSL connection
You could use the Net::Ping package. I'm not sure that this is a more efficent way to do it or not? The module offers many options, so check out the docs. Here's a quick implementation of the code you have above.
HTH
HTH
Also be careful of your comparison operator, it's == not =, probably a typo, but just wanted to bring it to your attention.#!/usr/bin/perl -w use Net::Ping; my @hosts = ('10.0.0.10','12.35.236.130'); my $p = Net::Ping->new('icmp') or die "Can't create ping obj: $!"; foreach my $host (@hosts) { if(!$p->ping($host, 2)) { print "$host down, do something\n"; } } $p->close();
|
---|
In Section
Seekers of Perl Wisdom