develooper Front page | perl.perl5.porters | Postings from February 2000

Re: fixing Sys::Hostname

Thread Previous | Thread Next
From:
Nick Ing-Simmons
Date:
February 8, 2000 05:52
Subject:
Re: fixing Sys::Hostname
Message ID:
200002081352.NAA23268@tiuk.ti.com
Russ Allbery <rra@stanford.edu> writes:
>Ilya Zakharevich <ilya@math.ohio-state.edu> writes:
>
>> But what will it return?  What *is* a host name?
>
>How about returning the result of gethostname in libc or throwing an
>exception if gethostname isn't implemented on that platform, just like
>symlink and the other core functions that aren't available on some OSes?
>And then if the VMS and Windows ports want to add their own native
>implementations (assuming they don't have gethostname), they can.

I rather like this part of VMS approach in Sys/Hostname.pm : 

  $host = (gethostbyname('me'))[0]

note that Win32 also does : 

  ($host) = gethostbyname('localhost');

Sadly most UNIX boxes don't add a sane alias to their /etc/hosts file
so that trick is not portable.

-- 
Nick Ing-Simmons <nik@tiuk.ti.com>
Via, but not speaking for: Texas Instruments Ltd.


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About