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

In reply to Re: Re: Re: wont run for long with strict. by rchiav
in thread wont run for long with strict. by rdnzl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.