Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Find a networked computer name

by dempa (Friar)
on Dec 20, 2002 at 13:22 UTC ( [id://221418]=note: print w/replies, xml ) Need Help??


in reply to Find a networked computer name

I don't know how portable this is. I'm on Unix. Also, this code needs checking of system call return values before serious use!
use Sys::Hostname; use Socket; my $hostname = gethostbyaddr(gethostbyname(hostname()),AF_INET); print "$hostname\n";

Update: The reason I included the calls to gethostby* is in case you want the domainname also. hostname() from Sys::Hostname doesn't always include that.

-- 
dempa

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://221418]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-04-25 22:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found