[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Is there a trick to gethostbyname()?



>At 13.23 -0500 12.28.1998, Michael Brian Bentley wrote:
>>Should there be something I need to set in a Mac OS control panel somewhere
>>to get this to fly? The machine is configured for TCP/IP and has an IP
>>address. The hostname function appears to provide the name of the machine
>>indicated in the File Sharing control panel.
>
>The File Sharing control panel has nothing to do with hostnames.
>
>If your machine does not have a name, you cannot get a name for it, and you
>cannot get a host by its name, since there is not one.
>
>  #!perl -wl
>  my $thishost = 'www.cfcl.com';
>  (my $name, undef) = gethostbyname($thishost);
>  print $name;
>
>Returns:
>
>  freebie.cfcl.com
>Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/

Thanks. In w3mir, the following code:

my $thishost = hostname();
( my $name, undef ) = gethostbyname( $thishost );

Assigns $thishost to the Network Identity "Computer Name" of the Mac, which
is set by the File Sharing control panel. Your example makes perfect sense;
I'm trying now to make sense of hostname() and why it selects that name,
and what the original author intended.

-m




***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch