Here is the part of the code that isn't doing what I expect it to.

It would be nice to tell us what you expect your code to do, and in which respect it does not do that.

A couple of comments on your code. It has already been pointed out that the $i3 variable is not used in your loop, which seems to be a possible error (but we do not know since we don't really know what you are trying to do). Having said that, that loop would be more perlish this way:

for my $i3 (1..9) { # ...
Similarly, the other loop:
for my $i (0..$#textarray) { # ...
The important thing above is not so much the different syntax, but the fact that this code declares the $i3 and $i variables with the my operator and gives them a lexical scope. All your variables should be declared and you should always use the following pragmas:
use strict; use warnings;
near the top of your program. They will help you finding errors or deprecated/dangerous constructs.

Update: fixed a missing closing parenthesis in one of my loop examples. Thanks to AnomalousMonk for pointing out the typo through the chatterbox.

In reply to Re: looping in 2d array by Laurent_R
in thread 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.