[Perl] gethostbyaddr function

Geffy

OSNN Veteran Addict
#1
I cant seem to figure out the proper usage of the Perl gethostbyaddr function, from what I can tell I have to use Socket, but then I am not sure exactly what the ADDRTYPE parameter is supposed to be

10.10.10.10 is an IP address which does have a reverse dns address on my local network

Code:
#!/usr/bin/perl -w
use Socket;
my $ip = "10.10.10.10";
my $addr = gethostbyaddr($ip, AF_INET);
print $addr;
if I do that I get an error, uninitialised value line 5 which is the print line

if I do either of the following I get nothing being returned
Code:
#!/usr/bin/perl -w
use Socket;
my $ip = "10.10.10.10";
my @addr = gethostbyaddr($ip, AF_INET);

foreach (@addr) {
    print;
}
or
Code:
#!/usr/bin/perl -w
use Socket;
my $ip = "10.10.10.10";
my @addr = gethostbyaddr($ip, AF_INET);
print @addr;
I cant seem to get any of them to work, the choice of AF_INET was from search results turned up by Google

Any help much appreciated
 

Members online

No members online now.

Latest posts

Latest profile posts

Perris Calderon wrote on Electronic Punk's profile.
Ep, glad to see you come back and tidy up...did want to ask a one day favor, I want to enhance my resume , was hoping you could make me administrator for a day, if so, take me right off since I won't be here to do anything, and don't know the slightest about the board, but it would be nice putting "served administrator osnn", if can do, THANKS

Been running around Quora lately, luv it there https://tinyurl.com/ycpxl
Electronic Punk wrote on Perris Calderon's profile.
All good still mate?
Hello, is there anybody in there? Just nod if you can hear me ...
Xie
What a long strange trip it's been. =)

Forum statistics

Threads
61,970
Messages
673,297
Members
89,016
Latest member
Poseeut