[Perl] gethostbyaddr function

Geffy

OSNN Veteran Addict
Joined
18 Mar 2002
Messages
7,805
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 profile posts

Also Hi EP and people. I found this place again while looking through a oooollllllldddd backup. I have filled over 10TB and was looking at my collection of antiques. Any bids on the 500Mhz Win 95 fix?
Any of the SP crew still out there?
Xie wrote on Electronic Punk's profile.
Impressed you have kept this alive this long EP! So many sites have come and gone. :(

Just did some crude math and I apparently joined almost 18yrs ago, how is that possible???
hello peeps... is been some time since i last came here.
Electronic Punk wrote on Sazar's profile.
Rest in peace my friend, been trying to find you and finally did in the worst way imaginable.

Forum statistics

Threads
62,015
Messages
673,494
Members
5,621
Latest member
naeemsafi
Back