in reply to novice falls

Let's start with this:
gethostbyaddr(192.168.1.1, AF_INET);
The fact that this works is sort of an accident. You're "supposed" to do something more like this:
$ip = inet_aton('192.168.1.1'); print gethostbyaddr($ip, AF_INET);
Your example appears to work as a side effect of a new string syntax intended to support unicode (and software version numbers like "5.6.0"). It does the right thing in your example but it doesn't appear to have been designed with IP addresses in mind.

Okay, but why does it fail in your second block of code? When perl is compiling your code and encounters "192.168.1.1" as a bare word, it packs the four bytes 192, 168, 1, and 1 into a four-characters string (this happens to be the same thing that inet_aton() returns, and that gethostbyaddr() is expecting to receive). This conversion process is part of the perl compilation process, i.e. it happens it compile time.

In your second example, you're asking for the same thing to happen at runtime. This isn't going to work. gethostbyaddr() is expecting to receive a four-byte string containing a packed IP address; instead it gets an 11-byte string containing a literal "192.168.1.1" (or similar).

Further, in your second example, you're using 'tcp' as the second argument to gethostbyaddr(). This isn't correct. You should supply AF_INET as you did in your first example.

In your second example, try replacing the gethostbyaddr() line with the following:

my $ip = inet_aton($&); my $name = gethostbyaddr($ip, AF_INET);