Ok, I’ve written a perl script that connects to a http server, gets a webpage, parses some info and writes results to a file. All is well except, I get these error messages when I run it:

 

Use of uninitialized value at ./stock.pl line 30, <GEN0> chunk 2.

Use of uninitialized value at ./stock.pl line 30, <GEN0> chunk 2.

Use of uninitialized value at ./stock.pl line 30, <GEN0> chunk 2.

Use of uninitialized value at ./stock.pl line 30, <GEN0> chunk 216.

Use of uninitialized value at ./stock.pl line 30, <GEN0> chunk 217.

 

These are sent to STDERR (of course).

 

The script is as follows:

 

#!/usr/bin/perl -w

 

use IO::Socket;

 

my($server);

my($remote);

my($time);

my($valueness);

my($doitnow);

my($in);

my($out);

my(@inness);

my($i);

 

$server = "quotes.nasdaq-amex.com";

 

$remote = IO::Socket::INET->new(Proto=>"tcp", PeerAddr=>$server, PeerPort=>"80", Reuse=>1)

    or die "Can't connect to \"$server\"\n";

 

# set buffering off

$remote->autoflush(1);

 

$out = "GET /quote.dll?page=multi&mode=stock&symbol=MSFT\r\n";

 

print $remote $out;

 

$in = <$remote>;

while (substr($in, 0, 7) ne "</html>") {

    $in = <$remote>;

    $inness[$i] = $inness[$i] . $in;

    $i++;

}

 

close $remote;

 

foreach (@inness) {

    if (substr($_, 0, 79) eq '            <td nowrap><font size=2 face="Arial,Helvetica,Veranda">Last Sale:</font></td>') {

        $doitnow = "yes";

    }

    if (substr($_, 0, 72) eq '            <td align=right><font size=2 face="Arial,Helvetica,Veranda"><nobr><b>$' && $doitnow eq "yes") {

        $valueness = substr($_, 73, (index($_, "</b>") - 73));

        $doitnow = "";

    }

}

 

open FILE, ">>stocks.txt";

$time = `date`;

chop $time;

print FILE $time . ": " . $valueness . "\n";

close FILE;

 

print "Stock update: $valueness" . "\n";

 

The error is obviously in this line:

 

    $inness[$i] = $inness[$i] . $in;

 

In case you’re 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

Reply via email to