Thank you. I just used "use strict" and "use warnings" and it worked. Even now I cant figure out what difference can this make :)
Thank you for tour time Anant On Thu, Oct 22, 2009 at 5:19 PM, Philip Potter <philip.g.pot...@gmail.com>wrote: > 2009/10/22 Anant Gupta <anantgupta...@gmail.com>: > > Nopes, > > It is the same > > > > The '-' minus sign was my mistake. > > > > I am using this on Red Hat Linux, but I am not the root user. > > Will not being the root user make any difference? > > No, it won't make any difference. > > This is probably quite frustrating for you, but I'm not sure what I > can do if the code works on my machine. I suggest you try the > following: > > * use warnings and use strict > * make the code simpler and simpler while still exhibiting the error > * post the *simplest* *complete* program which demonstrates your problem > * also post, verbatim, your command-line session demonstrating you > running the program on your system. > > For example, here is a command-line session from my machine, where I > first show a complete program (using 'cat foo.pl') and then run the > program, listing all errors. > > p...@teach:~/tmp$ cat foo.pl > use strict; > use warnings; > > $foo = 34; > print "$foo\n"; > p...@teach:~/tmp$ perl foo.pl > Global symbol "$foo" requires explicit package name at foo.pl line 4. > Global symbol "$foo" requires explicit package name at foo.pl line 5. > Execution of foo.pl aborted due to compilation errors. > p...@teach:~/tmp$ > > Doing it this way means we know: > * EXACTLY what you are running, because you have shown us a complete > program and not a snippet from the middle > --- Note that if you post a snippet rather than a complete program, > you run the risk that the error is not contained within the snippet. > * What perl itself thinks of your program, because you have used > strict and warnings > * The EXACT wording of the error message on your system > * What your program does on our systems, because we can copy and paste > it onto our own machine > > If you do this, we will have a much better chance of helping you. > Unfortunately, there are still no guarantees :( > > Philip > > > Thanks > > > > On Thu, Oct 22, 2009 at 4:33 PM, Philip Potter < > philip.g.pot...@gmail.com> > > wrote: > >> > >> 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 > > > > >