2009/10/22 Anant Gupta <anantgupta...@gmail.com>:
> I wrote
>
> #!usr/bin/perl
> use Socket;
> use constant ADDR => 'www.google.com';
> my $name=shift || ADDR;
> $packed=gethostbyname($name);
> $dotted-inet_ntoa($packed);
> print "DOtted Address is $packed";
>
> but it is showing an error
> "Bad argument length for Socket length in inet_ntoa" ???
> Help

When I run your code, I don't get any such error. Are you sure that
this is the code that produced the error?

Further:
> $dotted-inet_ntoa($packed);

did you mean
  $dotted = inet_ntoa($packed);
(you used a - minus sign instead of a = assignment operator)

> print "DOtted Address is $packed";

did you mean
  print "Dotted Address is $dotted\n";
you were printing the wrong variable.

With these changes, I get a dotted ip address which matches the output
of "host www.google.com"

Philip

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to