Code:
foreach $hostname (@hostnameUniqueSorted){
$ipaddr = inet_ntoa((gethostbyname($hostname))[4]);
if(chomp($ipaddr) =~ '^$') $ipaddr == "ip not avail"; <-- doesn't work
}
If the host doesn't return an IP address, it would break and show:
Usage: Socket::inet_ntoa(ip_address_sv) at ./abc line 24.
How do I catch it and assign maybe 'ip not avail' for the $ipaddr?
I added the last line but it doesn't work.