Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Answer: How do I get the local internet IP address?

by kschwab (Priest)
on Jan 23, 2001 at 19:28 UTC ( #53700=categorized answer: print w/replies, xml ) Need Help??

Q&A > network programming > How do I get the local internet IP address? - Answer contributed by kschwab

Works if Sys::Hostname comes up with a resolvable hostname.
use Sys::Hostname qw(hostname); # not strictly necessary; exports it b +y default use Socket; my($addr) = inet_ntoa( (gethostbyname(hostname()))[4] ); print "$addr\n";

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (10)
As of 2017-07-28 15:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (431 votes). Check out past polls.