Have you tried adding some print statements showing the values of your variables at each pass? This should help a lot with debugging (unless you are savvy with the debugger--but then why are you asking us! ;p) For instance, at loops and conditional statements, add something like:

print <<END_DEBUG if $DEBUG; \$m = $m \$n = $n \$j = $j \$row = $row END_DEBUG

The variables $m and $n are easy to mix up... if you didn't cut and paste your exact code, are you sure you haven't accidentally typed $m++ rather than $n++ somewhere? The debug output will help you locate mistakes that you can't find while staring at the code.

(Don't forget to put somewhere near the top of your code)

my $DEBUG = 1;

--Solo
--
You said you wanted to be around when I made a mistake; well, this could be it, sweetheart.

In reply to Re: Loop skipping by Solo
in thread Loop skipping by ringleader

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.