geektron has asked for the wisdom of the Perl Monks concerning the following question:
according to the Camel:
"In scalar context, gethostbyname returns only the host address.
I'm assuming this means: my $ip = gethostbyname foo.bar.net; would return an IP address. it returns the hostname.
and perldoc -f gethostbyname says that the get* functions return name:
" In scalar context, you get the name, unless the function was a lookup by name, in which case you get the other thing, whatever it is."
both documents lead me to believe that a scalar call to gethostbyname would return an IP address. but i only get the hostname.
I can use the long way ( $name, undef, undef, undef, @ips ) = gethostbyname foo.bar.net successfully.
so why doesn't the scalar call work?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: gethostbyname bug?
by chromatic (Archbishop) on Sep 09, 2000 at 04:49 UTC | |
by geektron (Curate) on Sep 09, 2000 at 04:53 UTC | |
by Nooks (Monk) on Sep 11, 2000 at 02:46 UTC | |
by geektron (Curate) on Sep 12, 2000 at 02:13 UTC | |
by Nooks (Monk) on Sep 12, 2000 at 02:58 UTC | |
|
Re: gethostbyname bug?
by redmist (Deacon) on Sep 09, 2000 at 05:11 UTC | |
by BastardOperator (Monk) on Sep 09, 2000 at 05:31 UTC | |
by redmist (Deacon) on Sep 09, 2000 at 06:16 UTC | |
by BastardOperator (Monk) on Sep 09, 2000 at 06:53 UTC | |
by OzzyOsbourne (Chaplain) on Sep 11, 2000 at 22:01 UTC | |
by geektron (Curate) on Sep 09, 2000 at 05:28 UTC |