Well If I'm guessing correctly, these line numbers are off by 25 from what you've posted here. the lines in question are 183, 219 and 224 (in the script that you posted).
First, is this is exact script that you're running? It doesn't make sense that it's off by 25 lines.
Second, I'm not going to run this script, but the errors you're getting are all related to the @words array. It looks like this array gets populated by reading a file from disk. Does this file exist? If so, there might be some bad entries in there that aren't being checked for properly. As for the uninitialized values in the "eq" statements, I'm guessing that your regex isn't matching anything and $1 isn't being populated. You should check for a match and not assume that you have one. Just expand your regex to be an if statement, only executing the following code if there's a match.
And for any who want to look at this and provide information, here's the lines in question..(I think)
....................................
sub spew() {
my $rnd = sprintf "%d", rand scalar @{$words[0]->{num}};
my $start = @{$words[0]->{num}}[$rnd-1];
my $s = "\u$words[$start]->{word}";
my $next = $start;
while($next != -1) {
# THIS NEXT LINE GENERATES THE ARRAY REF ERROR (I THINK) - rich
$rnd = sprintf "%d", rand scalar @{$words[$next]->{num}};
$next = @{$words[$next]->{num}}[$rnd];
if($next != -1) {
$s .= " $words[$next]->{word}";
}
}
$s .= ".";
$s =~ s/ /, /g;
return $s;
}
...................................
sub add_sentence() {
my $string = lc shift;
my @s = split "[.,!?]", $string;
foreach(@s) {
s/[^a-z-A-Z0-9 \t']+//g;
my @w = split " ";
my $next_push = -1;
my $old_index = 0;
#WON'T THIS STOMP ON $_ FROM THE foreach(@s)?
foreach(@w) {
my $index = scalar(@words);
my $i = find_word($_);
my $new_index = ($i == -1)?$index:$i;
if($i == -1) {
$words[$new_index] = {word => $_};
} else {
#WHY IS THIS EMPTY? -rich
}
push @{$words[$old_index]->{num}}, $new_index;
$string =~ /^(\w+)/;
#THE FIRST UNINIT VALUE ERROR - rich
if($1 eq $_) {
push @{$words[0]->{num}}, $index;
}
$string =~ /(\w+)$/;
#THE SECOND UNINIT VALUE ERROR - rich
if($1 eq $_) {
push @{$words[$new_index]->{num}}, -1;
}
$old_index = $new_index;
}
}
}
Rich
|