in reply to Re: gethostbyname bug?
in thread gethostbyname bug?

You shouldn't need to do this. gethostbyname() should in fact return only the packed ip when referenced as a scalar
my $packedIP = gethostbyname("www.perlmonks.org"); print join('.', unpack("C4", $packedIP)), "\n";
This should work like a champ, although (myself and OzzyOzbourne were talking about this in the chatterbox), someone (tilly?) mentioned that in 5.6 the unpack isn't necessary. I can't confirm this though.

Replies are listed 'Best First'.
(redmist) RE: RE: Re: gethostbyname bug?
by redmist (Deacon) on Sep 09, 2000 at 06:16 UTC
      Not ugly, just different. That's why Perl rules. TMTOWTDI ;)
RE: RE: Re: gethostbyname bug?
by OzzyOsbourne (Chaplain) on Sep 11, 2000 at 22:01 UTC
    This was my ending code on this. $input was a standard IP...
    @ip = split(/\./, $input); $newname=gethostbyaddr(pack("C4", @ip), AF_INET);
    -Ozzyosbourne