You have to problems with your arguments passed to
gethostbyaddr. First, you are correct
that
$& is not in the correct format.
You must pass it in packed
address format, which can be done using
Socket's
inet_aton to convert the address
from readable dotted form to network-ordered bytes.
(Perl's "version strings" appear to generate a similarlly
formatted string.)
Secondly, the second arg to
gethostbyaddr needs to be
a valid type of address, which would be
AF_INET, probably. You do not want 'tcp', because that is
a protocol, not a type of address. (In fact, TCP can and does have
different types of addresses, with IPv6.)
Note that it is a good idea to use capturing parenthesis
instead of $&, because capturing parenthesis
tend to make your program faster. (See also perlvar.)