in reply to Can I condense the variable usage here?
But you probably meant ($Host eq ''), didn't you? That would be a good thing to check, if the match, er, didn't. Easy enough:if ($pingObj->ping($IpAddress, 1)){ my $MachineName = uc(gethostbyaddr (inet_aton($IpAddress), AF_INET) +) or "[FAILED]"; $MachineName = ($MachineName =~ /^(.*?)(-UDP\w*)?\./i)[0]; print "$IpAddress\t$MachineName" if $VERBOSE; } else { print "$IpAddress\tNo Response\n" if $VERBOSE; }
# Assuming you won't have a machine named "0" $MachineName = ($MachineName =~ /^(.*?)(-UDP\w*)?\./i)[0] || ($IpAd +dress . '[NULL]');
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Can I condense the variable usage here?
by Ninthwave (Chaplain) on Dec 23, 2003 at 20:53 UTC |