Re: Addition to: How do I find out my hostname/domainname/IP address?

[email protected] ((Randal L. Schwartz))
Newsgroups perl.perlfaq.workers
Organization Stonehenge Consulting Services; Portland, Oregon, USA
Message-ID <[email protected]>
>>>>> "Brian" == Brian D Foy <[email protected]> writes:

Brian> In article <[email protected]>, <[email protected]>
Brian> wrote:

>> > 9.23: How do I find out my hostname/domainname/IP address?
>> >
>> >        my $addr = inet_ntoa(scalar gethostbyname($host || 'localhost'));
>> 
>> If the host name is not important, that can be simplified to:
>> 
>> my $addr = join(".", unpack C4,((gethostbyname "")[4]));


Brian> i've added this to my queue of things to catch up on.  i'm on
Brian> holiday at the moment, so don't expect anything soon. :)

Didn't work when I just tried it (OS X 10.2.3, airport connection).
Perhaps it's peculiar to some net setups and not others, or some Unix
flavors and not others.  In any case, it should be noted that it's not
portable.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[email protected]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.