Craig
'my' doesn't initialise a variable, it just declares it. The variable still
needs a value assigned to it. If it was a problem with 'strict' you would
get an error along the lines of 'Global symbol "$value" requires explicit
package name at line n' at compile time (ie the program wouldn't even start
to run). The error you're getting instead means that you're trying to use
$value before it has been given a value.
What it looks like is happening is that there is a problem with your while
loop
> while (defined ($line = <$remote>)) {
> $line = substr("$line",1);
> if ($line =~ /^IP Address/){
> ($ipaddress, $value) = split(/\s+:/, $line);
> }
> }
If either <$remote> returns no lines or none of those lines starts with "IP
Address", then no value will ever be put into $value and you will get the
errors you see (well done for using -w, otherwise you wouldn't have picked
these up :-). I don't know anything about IO::Socket, so I'm not sure that
you've got the usage right in 'while ($line = <$remote>)', but I suggest
that you put in a couple of print lines in that while loop to see why you're
not getting the data. Try:
while (defined ($line = <$remote>)) {
print $line; # Add this here to see if the loop is working
$line = substr("$line",1);
if ($line =~ /^IP Address/){
($ipaddress, $value) = split(/\s+:/, $line);
print $ipaddress; # This will test whether the if and split are
working.
}
}
Cheers,
Mark C
> -----Original Message-----
> From: Craig Monroe [mailto:[EMAIL PROTECTED]]
> Sent: 06 July 2001 23:07
> To: [EMAIL PROTECTED]
> Subject: Need help with errors - strict the problem?
>
>
> I wrote the following program to find the WAN IP address of
> router, then
> send it in an http request to the website of the organization for dns
> updating. Then, I have a mail message sent to myself
> notifying me of the
> update.
> I received the following errors. I am still somewhat of a newbie, so
> please have a little patience with me. The error messages are as
> follows:
>
>
> Use of uninitialized value in print at
> c:\windows\desktop\perl_hacks\dns_lwp-mai
> l.pl line 87.
>
> Line 87 is print $value;
> I thought I initialized this with my value;
> Is this because of strict? How would I pass that value if that is the
> case?
>
>
> ....and the answer is......
>
> good 24.147.206.7
>
> Use of uninitialized value in concatenation (.) at
> c:\windows\desktop\perl_hacks
> \dns_lwp-mail.pl line 104.
>
> line 104 is %mail = ( To => '[EMAIL PROTECTED]',
>