in reply to localhost IP in a dollar sign
perl -le'chomp($h=`hostname`);print +(join ".",unpack('C4', gethostbyname $h))'
or in you code you can expand it out something like:
chomp(my $host=`hostname`);
my @address=unpack('C4', gethostbyname $host);
print "ip address is " . (join ".", @address);
I am sure this can be a lot tidier. Of course on some hosts you may have multiple interfaces to worry about.
Cheers.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
| A reply falls below the community's threshold of quality. You may see it by logging in. |