in reply to hostname from ip

Wrong function. The one you're using is to look up the IP by name.
print join ".", unpack 'C*', scalar gethostbyname('mediamind.be');
-->
66.33.0.165
The fucntion you need to use, is gethostbyaddr(). Socket is used for the constant AF_INET, though you could use it for the more robust function inet_aton(), too, instead of the pack+split. See the example in perlfunc:gethostbyaddr.
use strict; my $ip = join ".", unpack 'C*', scalar gethostbyname('mediamind.be'); print "IP = $ip\n"; use Socket; my @result = gethostbyaddr pack('C*', split /\./, $ip), AF_INET; use Data::Dumper; $Data::Dumper::Useqq = 1; print Dumper @result;
-->
IP = 66.33.0.165
$VAR1 = "mediamind.be";
$VAR2 = "";
$VAR3 = 2;
$VAR4 = 4;
$VAR5 = "B!\0\245";