> Hi! I have version 5.005_03 and I'm using the Win32 version 
> of the Learning Perl book. I'm having trouble running a few 
> scripts. For example, when I run the following:
> 
> Exercise 16.1
> 
> foreach $host (@ARGV) {
>   ($name, $aliases, $addrtype, $length, @addrs) = 
> gethostbyname($host);
>   print "$host:\n";
>   
>   foreach $a (@addrs) {
>     print join(".", unpack("C4", $a)), "\n";
>   }
> }
> 
> ....I get the following errors:
> 
> Name "main::name" used only once: possible typo at 415.pl 
> line 5. Name "main::length" used only once: possible typo at 
> 415.pl line 5. Name "main::aliases" used only once: possible 
> typo at 415.pl line 5. Name "main::addrtype" used only once: 
> possible typo at 415.pl line 5.

Those aren't errors, they're warnings which get generated because you're
(wisely) asking for them by either having a -w at the end of the first
line of your program or including the 'use warnings;' pragma somewhere.
Your program should run correctly if those are the only messages it
generates.

> What am I doing wrong? The scripts in the book are supposedly 
> for this version but I'm having trouble with this and similar 
> scripts.

You shouldn't be declaring those variables as global if you're only
going to be using them in that one specific block. You don't even really
need to get the values if you're not going to use them. Use instead:

my @addrs = (gethostbyname($host))[4];

Hope that helps some, and please ask more specific questions with
relevant code attatched if I haven't answered what you were wondering
about.

 -dave



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to