I am attempting to do pattern matching for linguistic analysis using a 2 dimensional array. In one dimension are the words in English, in the second are all the grammar codes. I am new to PERL and programming in general, so I'm not sure if my problem is with the logic or the code.

Here is the part of the code that isn't doing what I expect it to. I have also left in my comments so you can see what I intend to do. Please let me know if you need more of my code to make any sense of this

Any suggestions would be great. Thanks!

$textarray[$iwrdnum][1] = $tagfields[0]; #the member located i +n the position 0 of the tagfields array, is placed into position 1 in + the textarray array $textarray[$iwrdnum][2] = $tagfields[1]; $textarray[$iwrdnum][3] = $tagfields[2]; $textarray[$iwrdnum][4] = $tagfields[3]; $textarray[$iwrdnum][5] = $tagfields[4]; $iwrdnum++; }#end loop 2 for ($i = 0; $i <@textarray; $i++) {#start loop 3 if ($textarray[$i][1] =~ /\b(nn|nns|nvbg|np|nps|npl)\b/) {#start if conditon for ($i3=1; $i3<=9; $i3++) #HERE IS WHERE I THINK + THE PROBLEM MUST BE. What I think I'm doing is starting at the next + row to the 9th row down, looking row by row { #start for loop if ($textarray[$i][1] =~ /\b(at|ati)\b/ ) #if +the tag is at or ati then {#start if condition print (OUTFILE "$textarray[$i][0]$textarra +y[$i+1][0]$textarray[$i+2][0]$textarray[$i+3][0]$textarray[$i+4][0]$t +extarray[$i+5]\n "); }#end if condition }#end for loop }#end if condition }#end loop 3

In reply to looping in 2d array by Linguist

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.