.................................... 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; } } }