You have a number of serious problems in this code, I'm afraid. I assume you succeeded in resolving those syntax errors at some point, since you say it never breaks out of the while loop, but since (as noted above) the code you posted does not compile, it's somewhat difficult to fix the logical errors.

However, since cLive ;-) seems to have given you some good advice on the compile-time problems, I'll try to guess what other problems you're about to run into. As I understand it, what you're trying to do is this:

for each column read each value in the column from the file perform a test on that value

The problem with the approach you're taking is that you're trying to read the file 682 times. While there's not necessarily a problem with that, you haven't taken any measures to make it work--you're ending the first run through at the end of the file, and you stay there for the rest of the script (look at seek for how to get around that).

If your table is merely in the range of 100s x 100s, though, I'd suggest instead reading the whole thing into memory: it's not necessarily scalable, but it's a heck of a lot easier to work with. Start with @lines = <FH>; just after you open it, and you can loop over it as many times as you like.

Alternatively, you can try the slightly more memory-hogging routine of

while (<FH>) { push @lines, [split]; }
and using @lines as what passes in Perl for a 2D array. However, if that didn't make instant sense to you, you might want to avoid it. :-)



If God had meant us to fly, he would *never* have given us the railroads.
    --Michael Flanders


In reply to Re: How to control the loop by ChemBoy
in thread How to control the loop by Anonymous Monk

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.