Ok, I see the problem now... the uninitialized value is $i. I did use my($I)
but that wasn't enough... my($i)=0 would be better... you have to keep in
mind I'm rather new to perl, so I didn't have the whole variable declaration
procedure down. Btw... I don't care much about efficiency right now, it's
just a script that gathers stock info for a social studies class. It works,
so I'm good with it.
Thanks for all your help guys...
-David
-----Original Message-----
From: Charles Galpin [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, December 07, 1999 8:28 PM
To: Redhat-list
Subject: Re: perl script has problems (kinda OT)
never thought of myself as a script kiddie, perhaps a guy who can write
scripts (and has kids), but nevertheless.
I can tell you why what you were doing doesn't work, but what you
are trying to do is rather silly. Not using -w isn't a good answer either
Iain :)
The reason it didn't work is because you are saying that you want to take
some value $inness[$i] and add the curren tline to it, then asign it to
$inness[$i]. Well, $inness[$i] is undefined each time you use it (because
you are incrementing $i. But again, this is silly because you really just
want the assignment
So, to preserve your current logic, use
$in = <$remote>;
$i=0;
while (substr($in, 0, 7) ne "</html>") {
$in = <$remote>;
$inness[$i] = $in;
$i++;
}
instead of
> $in = <$remote>;
> while (substr($in, 0, 7) ne "</html>") {
> $in = <$remote>;
> $inness[$i] = $inness[$i] . $in;
> $i++;
> }
but a better way would be
while (<$remote>) {
last if /^<\/html>/i;
push @inness, $_;
}
But, this is pointless. Just read from the socket and process it line by
line without the intermediate array. Also, I would get familiar with
regular expressions. You might as well be writing this in C the way you
are doing it.
>
> The error is obviously in this line:
>
> $inness[$i] = $inness[$i] . $in;
>
> In case youre wondering, this is for a school project.
>
> Can any of you script kiddies out there help me resolve this problem?
> (Preferably before school tomorrow : -)
>
> -David
>
btw, you have other warnigns related to $valueness which must not always
get set. To avoid these, initialize them like
my($valueness) = "UNKNOWN";
hth
charles
--
To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
as the Subject.
--
To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
as the Subject.