in reply to Re: variable not passing
in thread variable not passing

Thanks I tried this and still no luck:
use Socket; use strict; my $addy = shift || die "Enter a IP address"; my $port = getservbyname('smtp', 'tcp'); my $sin = sockaddr_in($port,inet_aton($addy)); my $client = gethostbyaddr($sin, AF_INET); # get name if ($client) { print $client, "\n\a"; } else { print "no\n"; }

Replies are listed 'Best First'.
Re^3: variable not passing
by gaal (Parson) on Dec 07, 2004 at 19:05 UTC
    You don't need this sin stuff here. Try your original code, but with the following replacement:

    # this: my $client = gethostbyaddr(inet_aton($addy), AF_INET); # get name # instead of: my $client = gethostbyaddr($addy, AF_INET); # get name

    It worked for you with the variable not received from the user because you weren't using quote marks, and you were getting a v-string (a deprecated feature, actually). Your luck was that a v-string is a lot like an inet_aton()-ed string :)

    Incidentally, why are you using Socket? Unless you want to use low-level stuff for learning or fine control, you are probably better off using IO::Socket. See perlipc, also.

      Thanks!!