Chuck Peters on Thu, 18 Apr 2002 08:34:38 -0400


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Perl Advisor: Doing Many Things, Like pings


An article by Randal L. Schwartz on UNIX Review
http://www.unixreview.com/documents/s=2426/uni1018362725458/0204g.htm
has a script for checking a subnet to see if host up and responding to
pings.  Script is also at http://ccil.org/~cp/perlping

I tried the script and its saying every IP on the subnet is up, which
isn't the case as I have 4 IP's on this LAN.  The script seems to be
failing at the test of:

sub ping_a_host {
  my $host = shift;
  'ping -i 1 -c 1 $host 2>/dev/null' =~ /0 packets rec/ ? 0 : 1;
}

Because I don't use perl frequently I don't understand the syntax and have
a hard time reading it.  What does the "=~ /0 packets rec/ ? 0 : 1" part
do?  Why is the test failing?

Thanks,
Chuck




**Majordomo list services provided by PANIX <URL:http://www.panix.com>**
**To Unsubscribe, send "unsubscribe phl" to majordomo@lists.pm.org**