• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

perl gethostbyaddress

pushVTEC

Senior member
So i'm parsing an access log so I have all the ips. I try to do gethostbyaddress($ip, AF_INET) and it doesn't return anything. What am I doing wrong? I've looked at examples it looks like I'm doing it right. All I want is the hostname to return.
 
I have

$key = inet_aton($key);
$b = gethostbyaddr($key, AF_INET);
print $b;

and it doesn't work, what am i doing wrong?
 
This works for me:

#!/usr/bin/perl
use Socket;
my $ip = inet_aton("66.51.174.166");
my $name = gethostbyaddr($ip, AF_INET);
print ("name = $name\n");
 
Back
Top